
n, m = map(int, input().split())

plants = []
min_plant_cost = 1000000000000000
min_plant_index = 0
for i in range(m):
    ci, ai = map(int, input().split())
    plants.append((ci-1, ai))
    if ai < min_plant_cost:
        min_plant_cost = ai
        min_plant_index = i

plants += [(i + n, cost) for i, cost in plants]
lines = list(map(int, input().split())) * 2

total_cost = plants[min_plant_index][1]
for num in lines[:n]:
    total_cost += num
    max_cost = max(max_cost, num)

for i in range(min_plant_index + 1, min_plant_index + m):
    # Try to build if it reduces costs.
    pass

cost = sum(lines)



# total_cost = plants[min_plant_index][1]

# for i in range(m - 2):
#     i += min_plant_index
#     index, cost = plants[i]
#     next_index, next_cost = plants[i+1]

#     # Walk to the next powerplant
#     cost_to_next = 0
#     max_line_cost = 0
#     for c in lines[index:next_index]:
#         cost_to_next += c
#         max_line_cost = max(max_line_cost, c)
    
#     # cost_to_next += next_cost
#     build_powerplant_cost = cost_to_next - max_line_cost + next_cost
#     if (cost_to_next < build_powerplant_cost):
#         # Just build the lines to the next powerplant
#         total_cost += cost_to_next;
#     else:
#         # Build the next poweplant.
#         total_cost += build_powerplant_cost


# # Handle last one
# i = min_plant_index + m - 2
# prev_index, prev_cost = plants[i]
# index, cost = plants[i+1]
# next_index, next_cost = plants[i+2]

# # Walk to the next powerplant
# cost_to_next = 0
# max_line_cost1 = 0
# max_line_cost2 = 0
# for c in lines[prev_index:index]:
#     cost_to_next += c
#     max_line_cost1 = max(max_line_cost1, c)

# for c in lines[index:next_index]:
#     cost_to_next += c
#     max_line_cost2 = max(max_line_cost2, c)

# # cost_to_next += next_cost
# nobuild_powerplant_cost = cost_to_next - max(max_line_cost1, max_line_cost2)
# build_powerplant_cost = cost_to_next - max_line_cost1 - max_line_cost2 + cost

# if (nobuild_powerplant_cost < build_powerplant_cost):
#     # Just build the lines to the next powerplant
#     total_cost += nobuild_powerplant_cost;
# else:
#     # Build the next poweplant.
#     total_cost += build_powerplant_cost

# print(total_cost)





############################################################





# n, m = map(int, input().split())

# costs = []
# for i in range(m):
#     ci, ai = map(int, input().split())
#     costs.append((True, ci-1, ai))

# costs += list((False, i, v) for i, v in enumerate(map(int, input().split())))


# costs = sorted(costs, key=lambda x: x[-1])

# powered = set({})
# total_cost = 0

# while len(powered) != n:
#     for index, (is_plant, i, cost) in enumerate(costs):
#         if is_plant:
#             if i not in powered:
#                 powered.add(i)
#                 total_cost += cost
#                 costs.pop(index)
#                 break
#         else:
#             currIn = i in powered
#             nextIn = (i+1)%n in powered
#             if currIn ^ nextIn:
#                 total_cost += cost
#                 if nextIn:
#                     powered.add(i)
#                 else
#                     powered.add((i+1)%n)
#                 costs.pop(index)
#                 break
    
        
# print(total_cost)



# # for ci, ai in building_cost:
# #     # Insert powerplant
# #     current_cost += ai

# #     # We kunnen 1 lijn removen:
# #     for c in line_cost:
# #         current_cost -= c
# #         min_cost = min(min_cost, current_cost)
# #         current_cost += c

# #     # Restore
# #     current_cost -= ai

# # Find cheapest way to add city:
# # avail_cities = []


# # print(min_cost)
