#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Created: Jul, 12, 2020 15:51:30 by Nobody
# $Author$
# $Date$
# $URL$
__giturl__ = "$URL$"


from collections import defaultdict
from sys import stdin
input = stdin.readline


def main():
  N, M = list(map(int, input().split()))
  A = sorted(list(map(int, input().split())))
  new = defaultdict(int)
  for _ in range(M):
    B, C = map(int, input().split())
    new[C] += B
  for x in A:
    new[x] += 1
  new = reversed(sorted([(k, v) for k, v in new.items()], key=lambda x: x[0]))
  ans = []
  for k, v in new:
    for i in range(v):
      ans.append(k)
      if len(ans) >= N:
        print(sum(ans))
        return
  print(sum(ans))

  # times = N
  # prev = 0
  # for k, v in new:
  #   idx = bisect.bisect_left(A[prev:], k) + prev
  #   times = v
  #   for i in range(idx):
  #     if not v:
  #       break
  #     times -= 1
  #     A[i] = k
  #   prev = min(prev+v, idx)


if(__name__ == '__main__'):
  main() __giturl__ = "$URL$" __giturl__ "$URL$" from collections import defaultdict from sys import stdin input = stdin.readline input stdin.readline stdin readline def main():
  N, M = list(map(int, input().split()))
  A = sorted(list(map(int, input().split())))
  new = defaultdict(int)
  for _ in range(M):
    B, C = map(int, input().split())
    new[C] += B
  for x in A:
    new[x] += 1
  new = reversed(sorted([(k, v) for k, v in new.items()], key=lambda x: x[0]))
  ans = []
  for k, v in new:
    for i in range(v):
      ans.append(k)
      if len(ans) >= N:
        print(sum(ans))
        return
  print(sum(ans))

  # times = N
  # prev = 0
  # for k, v in new:
  #   idx = bisect.bisect_left(A[prev:], k) + prev
  #   times = v
  #   for i in range(idx):
  #     if not v:
  #       break
  #     times -= 1
  #     A[i] = k
  #   prev = min(prev+v, idx) main N, M = list(map(int, input().split())) N list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split M A = sorted(list(map(int, input().split()))) A sorted(list(map(int, input().split()))) sorted list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split new = defaultdict(int) new defaultdict(int) defaultdict int for _ in range(M):
    B, C = map(int, input().split())
    new[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 new[C] += B new[C] new C B for x in A:
    new[x] += 1
   x A new[x] += 1 new[x] new x 1 (k, v) for k, v in new.items() for k, v in new.items() k v new.items() new.items new items for k, v in new.items() (k, v) k v new = reversed(sorted([(k, v) for k, v in new.items()], key=lambda x: x[0])) new reversed(sorted([(k, v) for k, v in new.items()], key=lambda x: x[0])) reversed sorted([(k, v) for k, v in new.items()], key=lambda x: x[0]) sorted [(k, v) for k, v in new.items()] key=lambda x: x[0] key lambda x: x[0] x[0] x 0 x ans = [] ans [] for k, v in new:
    for i in range(v):
      ans.append(k)
      if len(ans) >= N:
        print(sum(ans))
        return
   k v new for i in range(v):
      ans.append(k)
      if len(ans) >= N:
        print(sum(ans))
        return
   i range(v) range v ans.append(k) ans.append ans append k if len(ans) >= N:
        print(sum(ans))
        return
   len(ans) >= N len(ans) len ans N print(sum(ans)) print sum(ans) sum ans return print(sum(ans)) print sum(ans) sum ans if(__name__ == '__main__'):
  main() __name__ == '__main__' __name__ '__main__' main() main input = stdin.readline stdin.readline input def main():
  N, M = list(map(int, input().split()))
  A = sorted(list(map(int, input().split())))
  new = defaultdict(int)
  for _ in range(M):
    B, C = map(int, input().split())
    new[C] += B
  for x in A:
    new[x] += 1
  new = reversed(sorted([(k, v) for k, v in new.items()], key=lambda x: x[0]))
  ans = []
  for k, v in new:
    for i in range(v):
      ans.append(k)
      if len(ans) >= N:
        print(sum(ans))
        return
  print(sum(ans))

  # times = N
  # prev = 0
  # for k, v in new:
  #   idx = bisect.bisect_left(A[prev:], k) + prev
  #   times = v
  #   for i in range(idx):
  #     if not v:
  #       break
  #     times -= 1
  #     A[i] = k
  #   prev = min(prev+v, idx) def main():
  N, M = list(map(int, input().split()))
  A = sorted(list(map(int, input().split())))
  new = defaultdict(int)
  for _ in range(M):
    B, C = map(int, input().split())
    new[C] += B
  for x in A:
    new[x] += 1
  new = reversed(sorted([(k, v) for k, v in new.items()], key=lambda x: x[0]))
  ans = []
  for k, v in new:
    for i in range(v):
      ans.append(k)
      if len(ans) >= N:
        print(sum(ans))
        return
  print(sum(ans))

  # times = N
  # prev = 0
  # for k, v in new:
  #   idx = bisect.bisect_left(A[prev:], k) + prev
  #   times = v
  #   for i in range(idx):
  #     if not v:
  #       break
  #     times -= 1
  #     A[i] = k
  #   prev = min(prev+v, idx) main
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Created: Jul, 12, 2020 15:51:30 by Nobody
# $Author$
# $Date$
# $URL$
__giturl__ = "$URL$"


from collections import defaultdict
from sys import stdin
input = stdin.readline


def main():
  N, M = list(map(int, input().split()))
  A = sorted(list(map(int, input().split())))
  new = defaultdict(int)
  for _ in range(M):
    B, C = map(int, input().split())
    new[C] += B
  for x in A:
    new[x] += 1
  new = reversed(sorted([(k, v) for k, v in new.items()], key=lambda x: x[0]))
  ans = []
  for k, v in new:
    for i in range(v):
      ans.append(k)
      if len(ans) >= N:
        print(sum(ans))
        return
  print(sum(ans))

  # times = N
  # prev = 0
  # for k, v in new:
  #   idx = bisect.bisect_left(A[prev:], k) + prev
  #   times = v
  #   for i in range(idx):
  #     if not v:
  #       break
  #     times -= 1
  #     A[i] = k
  #   prev = min(prev+v, idx)


if(__name__ == '__main__'):
  main()
