n, m = map(int, input().split())
a = list(map(int, input().split()))
s = []

for i in range(n):
  s.append((a[i], 1))

for _ in range(m):
  b, c = map(int, input().split())
  s.append((c, b))
#  for j in range(b):
#    a.append(c)

s.sort(reverse=True)
idx = 0
sum = 0
for i in range(n):
  if idx + s[i][1] > n:
    sum += s[i][0] * (n-idx)
    break

  sum += s[i][0] * s[i][1]
  idx += s[i][1]


# for i in range(l-n, l):
#  sum += a[i]

print(sum)
 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 s = [] s [] for i in range(n):
  s.append((a[i], 1)) i range(n) range n s.append((a[i], 1)) s.append s append (a[i], 1) a[i] a i 1 for _ in range(m):
  b, c = map(int, input().split())
  s.append((c, b))
#  for j in range(b):
#    a.append(c) _ range(m) range m b, c = map(int, input().split()) b map(int, input().split()) map int input().split() ().split () input split c s.append((c, b)) s.append s append (c, b) c b s.sort(reverse=True) s.sort s sort reverse=True reverse True idx = 0 idx 0 sum = 0 sum 0 for i in range(n):
  if idx + s[i][1] > n:
    sum += s[i][0] * (n-idx)
    break

  sum += s[i][0] * s[i][1]
  idx += s[i][1]


# for i in range(l-n, l):
#  sum += a[i] i range(n) range n if idx + s[i][1] > n:
    sum += s[i][0] * (n-idx)
    break

   idx + s[i][1] > n idx + s[i][1] idx s[i][1] [i] s i 1 n sum += s[i][0] * (n-idx) sum s[i][0] * (n-idx) s[i][0] [i] s i 0 n-idx n idx break sum += s[i][0] * s[i][1] sum s[i][0] * s[i][1] s[i][0] [i] s i 0 s[i][1] [i] s i 1 idx += s[i][1] idx s[i][1] [i] s i 1 print(sum) print sum s = [] [] s m = map(int, input().split()) map(int, input().split()) m c = map(int, input().split()) map(int, input().split()) c sum = 0 0 sum b, c = map(int, input().split()) map(int, input().split()) b sum += s[i][0] * s[i][1] s[i][0] * s[i][1] sum idx = 0 0 idx sum += s[i][0] * (n-idx) s[i][0] * (n-idx) sum a = list(map(int, input().split())) list(map(int, input().split())) a n, m = map(int, input().split()) map(int, input().split()) n idx += s[i][1] s[i][1] idx
n, m = map(int, input().split())
a = list(map(int, input().split()))
s = []

for i in range(n):
  s.append((a[i], 1))

for _ in range(m):
  b, c = map(int, input().split())
  s.append((c, b))
#  for j in range(b):
#    a.append(c)

s.sort(reverse=True)
idx = 0
sum = 0
for i in range(n):
  if idx + s[i][1] > n:
    sum += s[i][0] * (n-idx)
    break

  sum += s[i][0] * s[i][1]
  idx += s[i][1]


# for i in range(l-n, l):
#  sum += a[i]

print(sum)

