n,m = map(int,input().split())
A = [int(i) for i in input().split()]
A.sort()
CB = []
for i in range(m):
   b,c = map(int,input().split())
   CB.append([c,b])
CB.sort(reverse=True)
ans = sum(A)
index = 0
for c,b in CB:
    for i in range(b):
        if index >=n:
            print(ans)
            exit()
        if A[index] < c:
            ans += c-A[index]
            A[index] = c
            index += 1
        else:
            print(ans)
            exit()
print(ans)
 n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i A = [int(i) for i in input().split()] A [int(i) for i in input().split()] A.sort() A.sort A sort CB = [] CB [] for i in range(m):
   b,c = map(int,input().split())
   CB.append([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 CB.append([c,b]) CB.append CB append [c,b] c b CB.sort(reverse=True) CB.sort CB sort reverse=True reverse True ans = sum(A) ans sum(A) sum A index = 0 index 0 for c,b in CB:
    for i in range(b):
        if index >=n:
            print(ans)
            exit()
        if A[index] < c:
            ans += c-A[index]
            A[index] = c
            index += 1
        else:
            print(ans)
            exit() c b CB for i in range(b):
        if index >=n:
            print(ans)
            exit()
        if A[index] < c:
            ans += c-A[index]
            A[index] = c
            index += 1
        else:
            print(ans)
            exit() i range(b) range b if index >=n:
            print(ans)
            exit()
         index >=n index n print(ans) print ans exit() exit if A[index] < c:
            ans += c-A[index]
            A[index] = c
            index += 1
        else:
            print(ans)
            exit() A[index] < c A[index] A index c ans += c-A[index] ans c-A[index] c A[index] A index A[index] = c A[index] A index c index += 1 index 1 print(ans) print ans exit() exit print(ans) print ans b,c = map(int,input().split()) map(int,input().split()) b m = map(int,input().split()) map(int,input().split()) m c = map(int,input().split()) map(int,input().split()) c ans = sum(A) sum(A) ans index += 1 1 index index = 0 0 index A = [int(i) for i in input().split()] [int(i) for i in input().split()] A n,m = map(int,input().split()) map(int,input().split()) n CB = [] [] CB ans += c-A[index] c-A[index] ans
n,m = map(int,input().split())
A = [int(i) for i in input().split()]
A.sort()
CB = []
for i in range(m):
   b,c = map(int,input().split())
   CB.append([c,b])
CB.sort(reverse=True)
ans = sum(A)
index = 0
for c,b in CB:
    for i in range(b):
        if index >=n:
            print(ans)
            exit()
        if A[index] < c:
            ans += c-A[index]
            A[index] = c
            index += 1
        else:
            print(ans)
            exit()
print(ans)

