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

import collections
dic = collections.Counter(A)

for _ in range(M):
    b, c = map(int, input().split())
    if c in dic:
        dic[c] += b
    else:
        dic[c] = b

ans, k = 0, 0
l = sorted(list(dic.keys()), key=lambda x: -x)
for a in l:
    if k + dic[a]<= N:      
        k += dic[a]  
        ans += a*dic[a]
    else:
        ans += a*(N-k)
        break

print(ans) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M *A, = map(int, input().split()) *A A map(int, input().split()) map int input().split() ().split () input split import collections collections dic = collections.Counter(A) dic collections.Counter(A) collections.Counter collections Counter A for _ in range(M):
    b, c = map(int, input().split())
    if c in dic:
        dic[c] += b
    else:
        dic[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 if c in dic:
        dic[c] += b
    else:
        dic[c] = b c in dic c dic dic[c] += b dic[c] dic c b dic[c] = b dic[c] dic c b ans, k = 0, 0 ans 0 k 0 l = sorted(list(dic.keys()), key=lambda x: -x) l sorted(list(dic.keys()), key=lambda x: -x) sorted list(dic.keys()) list dic.keys() dic.keys dic keys key=lambda x: -x key lambda x: -x -x x x for a in l:
    if k + dic[a]<= N:      
        k += dic[a]  
        ans += a*dic[a]
    else:
        ans += a*(N-k)
        break a l if k + dic[a]<= N:      
        k += dic[a]  
        ans += a*dic[a]
    else:
        ans += a*(N-k)
        break k + dic[a]<= N k + dic[a] k dic[a] dic a N k += dic[a] k dic[a] dic a ans += a*dic[a] ans a*dic[a] a dic[a] dic a ans += a*(N-k) ans a*(N-k) a N-k N k break print(ans) print ans ans += a*dic[a] a*dic[a] ans b, c = map(int, input().split()) map(int, input().split()) b c = map(int, input().split()) map(int, input().split()) c k = 0, 0 0 k ans += a*(N-k) a*(N-k) ans dic = collections.Counter(A) collections.Counter(A) dic ans, k = 0, 0 0 ans k += dic[a] dic[a] k l = sorted(list(dic.keys()), key=lambda x: -x) sorted(list(dic.keys()), key=lambda x: -x) l N, M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M
N, M = map(int, input().split())
*A, = map(int, input().split())

import collections
dic = collections.Counter(A)

for _ in range(M):
    b, c = map(int, input().split())
    if c in dic:
        dic[c] += b
    else:
        dic[c] = b

ans, k = 0, 0
l = sorted(list(dic.keys()), key=lambda x: -x)
for a in l:
    if k + dic[a]<= N:      
        k += dic[a]  
        ans += a*dic[a]
    else:
        ans += a*(N-k)
        break

print(ans)