import collections
n,m = map(int,input().split())
a = list(map(int,input().split()))
col = collections.Counter(a)
 
for i in range(m):
  b,c = map(int,input().split())
  col[c] += b
col = sorted(col.items(), key=lambda x:x[0],reverse=True)
 
ans=0
for k,v in col:
  if n <= v:
    ans += k*n
    break
  else:
    ans += k*v
    n -= v
print(ans) import collections collections 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 col = collections.Counter(a) col collections.Counter(a) collections.Counter collections Counter a for i in range(m):
  b,c = map(int,input().split())
  col[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 col[c] += b col[c] col c b col = sorted(col.items(), key=lambda x:x[0],reverse=True) col sorted(col.items(), key=lambda x:x[0],reverse=True) sorted col.items() col.items col 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 k,v in col:
  if n <= v:
    ans += k*n
    break
  else:
    ans += k*v
    n -= v k v col if n <= v:
    ans += k*n
    break
  else:
    ans += k*v
    n -= v n <= v n v ans += k*n ans k*n k n break ans += k*v ans k*v k v n -= v n v print(ans) print ans b,c = map(int,input().split()) map(int,input().split()) b ans=0 0 ans m = map(int,input().split()) map(int,input().split()) m col = collections.Counter(a) collections.Counter(a) col c = map(int,input().split()) map(int,input().split()) c a = list(map(int,input().split())) list(map(int,input().split())) a n,m = map(int,input().split()) map(int,input().split()) n n -= v v n ans += k*n k*n ans ans += k*v k*v ans col = sorted(col.items(), key=lambda x:x[0],reverse=True) sorted(col.items(), key=lambda x:x[0],reverse=True) col
import collections
n,m = map(int,input().split())
a = list(map(int,input().split()))
col = collections.Counter(a)
 
for i in range(m):
  b,c = map(int,input().split())
  col[c] += b
col = sorted(col.items(), key=lambda x:x[0],reverse=True)
 
ans=0
for k,v in col:
  if n <= v:
    ans += k*n
    break
  else:
    ans += k*v
    n -= v
print(ans)