N,M=map(int,input().split())
S=list(map(int,input().split()))
S.sort()

TRADE=[[0 for j in range(2)] for i in range(M)]

for i in range(M):
    B,C=map(int,input().split())
    TRADE[i][0]=B
    TRADE[i][1]=C


T=sorted(TRADE,key=lambda x:x[1],reverse=True)


TLEN=0
pos=0
flag=True
while TLEN<M and flag==True:
    for i in range(T[TLEN][0]):
        if S[pos]<T[TLEN][1]:
            S[pos]=T[TLEN][1]
            pos+=1
        else:
            flag=False
            break
        if pos>len(S)-1:
            flag=False
            break
    TLEN+=1

print(sum(S)) N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M S=list(map(int,input().split())) S list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split S.sort() S.sort S sort [0 for j in range(2)] for i in range(M) for i in range(M) i range(M) range M for i in range(M) [0 for j in range(2)] TRADE=[[0 for j in range(2)] for i in range(M)] TRADE [[0 for j in range(2)] for i in range(M)] for i in range(M):
    B,C=map(int,input().split())
    TRADE[i][0]=B
    TRADE[i][1]=C i range(M) range M B,C=map(int,input().split()) B map(int,input().split()) map int input().split() ().split () input split C TRADE[i][0]=B TRADE[i][0] [i] TRADE i 0 B TRADE[i][1]=C TRADE[i][1] [i] TRADE i 1 C T=sorted(TRADE,key=lambda x:x[1],reverse=True) T sorted(TRADE,key=lambda x:x[1],reverse=True) sorted TRADE key=lambda x:x[1] key lambda x:x[1] x[1] x 1 x reverse=True reverse True TLEN=0 TLEN 0 pos=0 pos 0 flag=True flag True while TLEN<M and flag==True:
    for i in range(T[TLEN][0]):
        if S[pos]<T[TLEN][1]:
            S[pos]=T[TLEN][1]
            pos+=1
        else:
            flag=False
            break
        if pos>len(S)-1:
            flag=False
            break
    TLEN+=1 TLEN<M and flag==True TLEN<M TLEN M flag==True flag True for i in range(T[TLEN][0]):
        if S[pos]<T[TLEN][1]:
            S[pos]=T[TLEN][1]
            pos+=1
        else:
            flag=False
            break
        if pos>len(S)-1:
            flag=False
            break
     i range(T[TLEN][0]) range T[TLEN][0] [TLEN] T TLEN 0 if S[pos]<T[TLEN][1]:
            S[pos]=T[TLEN][1]
            pos+=1
        else:
            flag=False
            break
         S[pos]<T[TLEN][1] S[pos] S pos T[TLEN][1] [TLEN] T TLEN 1 S[pos]=T[TLEN][1] S[pos] S pos T[TLEN][1] [TLEN] T TLEN 1 pos+=1 pos 1 flag=False flag False break if pos>len(S)-1:
            flag=False
            break
     pos>len(S)-1 pos len(S)-1 len(S) len S 1 flag=False flag False break TLEN+=1 TLEN 1 print(sum(S)) print sum(S) sum S C=map(int,input().split()) map(int,input().split()) C T=sorted(TRADE,key=lambda x:x[1],reverse=True) sorted(TRADE,key=lambda x:x[1],reverse=True) T TLEN=0 0 TLEN flag=True True flag flag=False False flag TLEN+=1 1 TLEN pos=0 0 pos N,M=map(int,input().split()) map(int,input().split()) N pos+=1 1 pos S=list(map(int,input().split())) list(map(int,input().split())) S flag=False False flag M=map(int,input().split()) map(int,input().split()) M TRADE=[[0 for j in range(2)] for i in range(M)] [[0 for j in range(2)] for i in range(M)] TRADE B,C=map(int,input().split()) map(int,input().split()) B
N,M=map(int,input().split())
S=list(map(int,input().split()))
S.sort()

TRADE=[[0 for j in range(2)] for i in range(M)]

for i in range(M):
    B,C=map(int,input().split())
    TRADE[i][0]=B
    TRADE[i][1]=C


T=sorted(TRADE,key=lambda x:x[1],reverse=True)


TLEN=0
pos=0
flag=True
while TLEN<M and flag==True:
    for i in range(T[TLEN][0]):
        if S[pos]<T[TLEN][1]:
            S[pos]=T[TLEN][1]
            pos+=1
        else:
            flag=False
            break
        if pos>len(S)-1:
            flag=False
            break
    TLEN+=1

print(sum(S))