"""
優先度付きキューで実装
"""
import heapq

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

a_pq = []

for i in a_list:
    heapq.heappush(a_pq, [-i, 1])

for i in range(m):
    b, c = map(int, input().split())
    heapq.heappush(a_pq, [-c, b])

ans = 0
for i in range(n):
    pop_tmp = heapq.heappop(a_pq)
    number, sum_number = pop_tmp
    ans += -number
    if sum_number > 1:
        sum_number -= 1
        heapq.heappush(a_pq, [number, sum_number])

print(ans) """
優先度付きキューで実装
""" import heapq heapq n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m a_list = list(map(int, input().split())) a_list list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split a_pq = [] a_pq [] for i in a_list:
    heapq.heappush(a_pq, [-i, 1]) i a_list heapq.heappush(a_pq, [-i, 1]) heapq.heappush heapq heappush a_pq [-i, 1] -i i 1 for i in range(m):
    b, c = map(int, input().split())
    heapq.heappush(a_pq, [-c, b]) i range(m) range m b, c = map(int, input().split()) b map(int, input().split()) map int input().split() ().split () input split c heapq.heappush(a_pq, [-c, b]) heapq.heappush heapq heappush a_pq [-c, b] -c c b ans = 0 ans 0 for i in range(n):
    pop_tmp = heapq.heappop(a_pq)
    number, sum_number = pop_tmp
    ans += -number
    if sum_number > 1:
        sum_number -= 1
        heapq.heappush(a_pq, [number, sum_number]) i range(n) range n pop_tmp = heapq.heappop(a_pq) pop_tmp heapq.heappop(a_pq) heapq.heappop heapq heappop a_pq number, sum_number = pop_tmp number pop_tmp sum_number ans += -number ans -number number if sum_number > 1:
        sum_number -= 1
        heapq.heappush(a_pq, [number, sum_number]) sum_number > 1 sum_number 1 sum_number -= 1 sum_number 1 heapq.heappush(a_pq, [number, sum_number]) heapq.heappush heapq heappush a_pq [number, sum_number] number sum_number print(ans) print ans sum_number -= 1 1 sum_number pop_tmp = heapq.heappop(a_pq) heapq.heappop(a_pq) pop_tmp a_list = list(map(int, input().split())) list(map(int, input().split())) a_list ans = 0 0 ans ans += -number -number ans a_pq = [] [] a_pq c = map(int, input().split()) map(int, input().split()) c number, sum_number = pop_tmp pop_tmp number sum_number = pop_tmp pop_tmp sum_number m = map(int, input().split()) map(int, input().split()) m n, m = map(int, input().split()) map(int, input().split()) n b, c = map(int, input().split()) map(int, input().split()) b
"""
優先度付きキューで実装
"""
import heapq

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

a_pq = []

for i in a_list:
    heapq.heappush(a_pq, [-i, 1])

for i in range(m):
    b, c = map(int, input().split())
    heapq.heappush(a_pq, [-c, b])

ans = 0
for i in range(n):
    pop_tmp = heapq.heappop(a_pq)
    number, sum_number = pop_tmp
    ans += -number
    if sum_number > 1:
        sum_number -= 1
        heapq.heappush(a_pq, [number, sum_number])

print(ans)
