import sys
input = sys.stdin.readline

N,M=(int(x) for x in input().rstrip('\n').split())
As = [int(x) for x in input().rstrip('\n').split()]
d = {}
for x in As:
  if x in d:
    d[x] += 1
  else:
    d[x] = 1
for _ in range(M):
  B,C = (int(x) for x in input().rstrip('\n').split())
  if C in d:
    d[C] += B
  else:
    d[C] = B
res = 0
rest = N
d2 = sorted([x for x in d.keys()],reverse=True)
for m in d2:
  x = d[m]
  if rest < x:
    res += rest*m
    break
  else:
    res += x*m
    rest -= x
print(res) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline int(x) for x in input().rstrip('\n').split() for x in input().rstrip('\n').split() x input().rstrip('\n').split() ().rstrip('\n').split ().rstrip('\n') ().rstrip () input rstrip '\n' split for x in input().rstrip('\n').split() int(x) int x N,M=(int(x) for x in input().rstrip('\n').split()) N (int(x) for x in input().rstrip('\n').split()) M int(x) for x in input().rstrip('\n').split() for x in input().rstrip('\n').split() x input().rstrip('\n').split() ().rstrip('\n').split ().rstrip('\n') ().rstrip () input rstrip '\n' split for x in input().rstrip('\n').split() int(x) int x As = [int(x) for x in input().rstrip('\n').split()] As [int(x) for x in input().rstrip('\n').split()] d = {} d {} for x in As:
  if x in d:
    d[x] += 1
  else:
    d[x] = 1 x As if x in d:
    d[x] += 1
  else:
    d[x] = 1 x in d x d d[x] += 1 d[x] d x 1 d[x] = 1 d[x] d x 1 for _ in range(M):
  B,C = (int(x) for x in input().rstrip('\n').split())
  if C in d:
    d[C] += B
  else:
    d[C] = B _ range(M) range M int(x) for x in input().rstrip('\n').split() for x in input().rstrip('\n').split() x input().rstrip('\n').split() ().rstrip('\n').split ().rstrip('\n') ().rstrip () input rstrip '\n' split for x in input().rstrip('\n').split() int(x) int x B,C = (int(x) for x in input().rstrip('\n').split()) B (int(x) for x in input().rstrip('\n').split()) C if C in d:
    d[C] += B
  else:
    d[C] = B C in d C d d[C] += B d[C] d C B d[C] = B d[C] d C B res = 0 res 0 rest = N rest N x for x in d.keys() for x in d.keys() x d.keys() d.keys d keys for x in d.keys() x d2 = sorted([x for x in d.keys()],reverse=True) d2 sorted([x for x in d.keys()],reverse=True) sorted [x for x in d.keys()] reverse=True reverse True for m in d2:
  x = d[m]
  if rest < x:
    res += rest*m
    break
  else:
    res += x*m
    rest -= x m d2 x = d[m] x d[m] d m if rest < x:
    res += rest*m
    break
  else:
    res += x*m
    rest -= x rest < x rest x res += rest*m res rest*m rest m break res += x*m res x*m x m rest -= x rest x print(res) print res res += rest*m rest*m res res += x*m x*m res N,M=(int(x) for x in input().rstrip('\n').split()) (int(x) for x in input().rstrip('\n').split()) N B,C = (int(x) for x in input().rstrip('\n').split()) (int(x) for x in input().rstrip('\n').split()) B rest -= x x rest M=(int(x) for x in input().rstrip('\n').split()) (int(x) for x in input().rstrip('\n').split()) M input = sys.stdin.readline sys.stdin.readline input d = {} {} d x = d[m] d[m] x res = 0 0 res C = (int(x) for x in input().rstrip('\n').split()) (int(x) for x in input().rstrip('\n').split()) C rest = N N rest d2 = sorted([x for x in d.keys()],reverse=True) sorted([x for x in d.keys()],reverse=True) d2 As = [int(x) for x in input().rstrip('\n').split()] [int(x) for x in input().rstrip('\n').split()] As
import sys
input = sys.stdin.readline

N,M=(int(x) for x in input().rstrip('\n').split())
As = [int(x) for x in input().rstrip('\n').split()]
d = {}
for x in As:
  if x in d:
    d[x] += 1
  else:
    d[x] = 1
for _ in range(M):
  B,C = (int(x) for x in input().rstrip('\n').split())
  if C in d:
    d[C] += B
  else:
    d[C] = B
res = 0
rest = N
d2 = sorted([x for x in d.keys()],reverse=True)
for m in d2:
  x = d[m]
  if rest < x:
    res += rest*m
    break
  else:
    res += x*m
    rest -= x
print(res)