n,m=map(int, input().split())
a=list(map(int,input().split()))
a.sort()
cb=[0]*m
for i in range(m):
    b,c=map(int, input().split())
    cb[i]=(c,b)
cb.sort(reverse=True)

i=0
for j in range(m):
    for k in range(cb[j][1]):
        a[i]=max(cb[j][0],a[i])
        i+=1
        if i>=n:
            break
    else:
        continue
    break
print(sum(a)) 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() a.sort a sort cb=[0]*m cb [0]*m [0] 0 m for i in range(m):
    b,c=map(int, input().split())
    cb[i]=(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[i]=(c,b) cb[i] cb i (c,b) c b cb.sort(reverse=True) cb.sort cb sort reverse=True reverse True i=0 i 0 for j in range(m):
    for k in range(cb[j][1]):
        a[i]=max(cb[j][0],a[i])
        i+=1
        if i>=n:
            break
    else:
        continue
    break j range(m) range m for k in range(cb[j][1]):
        a[i]=max(cb[j][0],a[i])
        i+=1
        if i>=n:
            break
    else:
        continue
     k range(cb[j][1]) range cb[j][1] [j] cb j 1 a[i]=max(cb[j][0],a[i]) a[i] a i max(cb[j][0],a[i]) max cb[j][0] [j] cb j 0 a[i] a i i+=1 i 1 if i>=n:
            break
     i>=n i n break continue break print(sum(a)) print sum(a) sum a n,m=map(int, input().split()) map(int, input().split()) n c=map(int, input().split()) map(int, input().split()) c i+=1 1 i b,c=map(int, input().split()) map(int, input().split()) b cb=[0]*m [0]*m cb m=map(int, input().split()) map(int, input().split()) m a=list(map(int,input().split())) list(map(int,input().split())) a i=0 0 i
n,m=map(int, input().split())
a=list(map(int,input().split()))
a.sort()
cb=[0]*m
for i in range(m):
    b,c=map(int, input().split())
    cb[i]=(c,b)
cb.sort(reverse=True)

i=0
for j in range(m):
    for k in range(cb[j][1]):
        a[i]=max(cb[j][0],a[i])
        i+=1
        if i>=n:
            break
    else:
        continue
    break
print(sum(a))