from collections import Counter

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

cnt = Counter(lis)

for _ in range(m):
    b,c = map(int,input().split())
    cnt[c] += b

anslis = sorted(cnt.items(), key=lambda x:x[0], reverse=True)

ans = 0
for key, value in anslis:
    if n > value:
        ans += key*value
        n -= value
    else:
        ans += n*key
        print(ans)
        break from collections import Counter n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m lis = list(map(int, input().split())) lis list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split cnt = Counter(lis) cnt Counter(lis) Counter lis for _ in range(m):
    b,c = map(int,input().split())
    cnt[c] += b _ range(m) range m b,c = map(int,input().split()) b map(int,input().split()) map int input().split() ().split () input split c cnt[c] += b cnt[c] cnt c b anslis = sorted(cnt.items(), key=lambda x:x[0], reverse=True) anslis sorted(cnt.items(), key=lambda x:x[0], reverse=True) sorted cnt.items() cnt.items cnt items key=lambda x:x[0] key lambda x:x[0] x[0] x 0 x reverse=True reverse True ans = 0 ans 0 for key, value in anslis:
    if n > value:
        ans += key*value
        n -= value
    else:
        ans += n*key
        print(ans)
        break key value anslis if n > value:
        ans += key*value
        n -= value
    else:
        ans += n*key
        print(ans)
        break n > value n value ans += key*value ans key*value key value n -= value n value ans += n*key ans n*key n key print(ans) print ans break m = map(int, input().split()) map(int, input().split()) m b,c = map(int,input().split()) map(int,input().split()) b ans += n*key n*key ans n, m = map(int, input().split()) map(int, input().split()) n ans = 0 0 ans ans += key*value key*value ans n -= value value n c = map(int,input().split()) map(int,input().split()) c anslis = sorted(cnt.items(), key=lambda x:x[0], reverse=True) sorted(cnt.items(), key=lambda x:x[0], reverse=True) anslis lis = list(map(int, input().split())) list(map(int, input().split())) lis cnt = Counter(lis) Counter(lis) cnt
from collections import Counter

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

cnt = Counter(lis)

for _ in range(m):
    b,c = map(int,input().split())
    cnt[c] += b

anslis = sorted(cnt.items(), key=lambda x:x[0], reverse=True)

ans = 0
for key, value in anslis:
    if n > value:
        ans += key*value
        n -= value
    else:
        ans += n*key
        print(ans)
        break
