n,m = list(map(int,input().split()))

a = list(map(int,input().split()))

a.sort()

d = []

for _ in range(m):

  b,c = list(map(int,input().split()))

  d.append([c,b])

d.sort(reverse = True)

e = []

f = 0

for j in range(m):

  for k in range(d[j][1]):

    e.append(d[j][0])

    f += 1

    if f == n:

      break

  else:

    continue

  break

else:

  e += [0] * (n-len(e))

ans = 0

#print(a)

#print(e)

for i in range(n):

  ans += max(a[i],e[i])

print(ans)
#15:40

n,m = list(map(int,input().split()))

a = list(map(int,input().split()))

a.sort()

bc = []

for _ in range(m):

  bc.append(list(map(int,input().split())))

bc.sort(key=lambda x: -x[1])

d = []

dl = 0

for x in bc:

  b,c = x

  d += [c] * b

  dl += b

  if dl >= n:

    break

if dl < n:

  d += [0] * (n-dl)

ans = []

for i in range(n):

  ans.append(max(a[i],d[i]))

#print(a)

#print(d)

#print(ans)

print((sum(ans)))
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
d = []
for _ in range(m):
    b, c = list(map(int, input().split()))
    d.append([c, b])
d.sort(reverse=True)
e = []
f = 0
for j in range(m):
    for k in range(d[j][1]):
        e.append(d[j][0])
        f += 1
        if f == n:
            break
    else:
        continue
    break
else:
    e += [0] * (n - len(e))
ans = 0
# print(a)
# print(e)
for i in range(n):
    ans += max(a[i], e[i])
print(ans)

# 15:40
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
bc = []
for _ in range(m):
    bc.append(list(map(int, input().split())))
bc.sort(key=lambda x: -x[1])
d = []
dl = 0
for x in bc:
    b, c = x
    d += [c] * b
    dl += b
    if dl >= n:
        break
if dl < n:
    d += [0] * (n - dl)
ans = []
for i in range(n):
    ans.append(max(a[i], d[i]))
# print(a)
# print(d)
# print(ans)
print((sum(ans)))

+# 15:40 +bc = [] +for _ in range(m): +    bc.append(list(map(int, input().split()))) +bc.sort(key=lambda x: -x[1]) -for _ in range(m): -    b, c = list(map(int, input().split())) -    d.append([c, b]) -d.sort(reverse=True) -e = [] -f = 0 -for j in range(m): -    for k in range(d[j][1]): -        e.append(d[j][0]) -        f += 1 -        if f == n: -            break -    else: -        continue -    break -else: -    e += [0] * (n - len(e)) -ans = 0 +dl = 0 +for x in bc: +    b, c = x +    d += [c] * b +    dl += b +    if dl >= n: +        break +if dl < n: +    d += [0] * (n - dl) +ans = [] +for i in range(n): +    ans.append(max(a[i], d[i])) -# print(e) -for i in range(n): -    ans += max(a[i], e[i]) -print(ans) +# print(d) +# print(ans) +print((sum(ans)))