N,M = map(int,input().split())

A = list(map(int,input().split()))
A.sort(reverse=True)
BC = []
for _ in range(M):
    B, C = (int(x) for x in input().split())
    BC.append([B, C])
BC = sorted(BC, key=lambda x: -x[1])

index = 0

ans = 0

while index < M and len(A) and A[-1] < BC[index][1]:
    b, c = BC[index]
    count = 0
    while len(A) and A[-1] < c and count < b:
        A.pop()
        ans += c
        count += 1
    index += 1
print(sum(A)+ans) N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M A = list(map(int,input().split())) A list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split A.sort(reverse=True) A.sort A sort reverse=True reverse True BC = [] BC [] for _ in range(M):
    B, C = (int(x) for x in input().split())
    BC.append([B, C]) _ range(M) range M int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x B, C = (int(x) for x in input().split()) B (int(x) for x in input().split()) C BC.append([B, C]) BC.append BC append [B, C] B C BC = sorted(BC, key=lambda x: -x[1]) BC sorted(BC, key=lambda x: -x[1]) sorted BC key=lambda x: -x[1] key lambda x: -x[1] -x[1] x[1] x 1 x index = 0 index 0 ans = 0 ans 0 while index < M and len(A) and A[-1] < BC[index][1]:
    b, c = BC[index]
    count = 0
    while len(A) and A[-1] < c and count < b:
        A.pop()
        ans += c
        count += 1
    index += 1 index < M and len(A) and A[-1] < BC[index][1] index < M and len(A) index < M index M len(A) len A A[-1] < BC[index][1] A[-1] A -1 BC[index][1] [index] BC index 1 b, c = BC[index] b BC[index] BC index c count = 0 count 0 while len(A) and A[-1] < c and count < b:
        A.pop()
        ans += c
        count += 1
     len(A) and A[-1] < c and count < b len(A) and A[-1] < c len(A) len A A[-1] < c A[-1] A -1 c count < b count b A.pop() A.pop A pop ans += c ans c count += 1 count 1 index += 1 index 1 print(sum(A)+ans) print sum(A)+ans sum(A) sum A ans count += 1 1 count BC = sorted(BC, key=lambda x: -x[1]) sorted(BC, key=lambda x: -x[1]) BC ans = 0 0 ans M = map(int,input().split()) map(int,input().split()) M index = 0 0 index B, C = (int(x) for x in input().split()) (int(x) for x in input().split()) B b, c = BC[index] BC[index] b C = (int(x) for x in input().split()) (int(x) for x in input().split()) C A = list(map(int,input().split())) list(map(int,input().split())) A index += 1 1 index N,M = map(int,input().split()) map(int,input().split()) N ans += c c ans count = 0 0 count BC = [] [] BC c = BC[index] BC[index] c
N,M = map(int,input().split())

A = list(map(int,input().split()))
A.sort(reverse=True)
BC = []
for _ in range(M):
    B, C = (int(x) for x in input().split())
    BC.append([B, C])
BC = sorted(BC, key=lambda x: -x[1])

index = 0

ans = 0

while index < M and len(A) and A[-1] < BC[index][1]:
    b, c = BC[index]
    count = 0
    while len(A) and A[-1] < c and count < b:
        A.pop()
        ans += c
        count += 1
    index += 1
print(sum(A)+ans)