# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop, heapify
import copy
import numpy as np
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


def main():
    n, m = LI()
    a = sorted(list(LI()))
    # 1. c以下をcに毎回置き換え.
    # for i in range(m):
    #     b, c = LI()
    #     for j in range(b):
    #         if a[j] > c:
    #             break
    #         heappushpop(a, c)
    # print(sum(a))

    # 2. 大きいcから入れていってbの累計がlen(a)になったら即終わり.
    # bc = LIR(m)
    # bc.sort(key=lambda x: x[1])
    # cnt = 0
    # for pair in bc:
    #     heappushpop(a, pair[1])
    #     cnt += pair[0]
    #     if cnt > len(a):
    #         break
    # print(sum(a))

    bc = LIR(m)
    bc.sort(key=lambda x: x[1], reverse=True)
    d = []
    i = 0
    while len(d) < n and i < len(bc):
        if bc[i][0] + len(d) < n:
            d.extend([bc[i][1]] * bc[i][0])
        else:
            d.extend([bc[i][1]] * (n - len(d)))
            break
        i += 1
    for i in range(len(d)):
        if d[i] < a[i]:
            break
        a[i] = d[i]
    print(sum(a))


if __name__ == "__main__":
    main() from math import floor, ceil, sqrt, factorial, log, gcd from itertools import accumulate, permutations, combinations, product, combinations_with_replacement from bisect import bisect_left, bisect_right from collections import Counter, defaultdict from heapq import heappop, heappush, heappushpop, heapify import copy copy import numpy as np numpy import sys sys INF = float('inf') INF float('inf') float 'inf' mod = 10**9+7 mod 10**9+7 10**9 10 9 7 sys.setrecursionlimit(10 ** 6) sys.setrecursionlimit sys setrecursionlimit 10 ** 6 10 6 def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI() lcm a a b b def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I() LI def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS() I def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S() LS def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2] S I() for i in range(n) for i in range(n) i range(n) range n for i in range(n) I() I def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]] IR n n LI() for i in range(n) for i in range(n) i range(n) range n for i in range(n) LI() LI def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def] LIR n n S() for i in range(n) for i in range(n) i range(n) range n for i in range(n) S() S def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]] SR n n LS() for i in range(n) for i in range(n) i range(n) range n for i in range(n) LS() LS def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]] LSR n n list(S()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) list(S()) list S() S def SRL(n): return [list(S()) for i in range(n)] SRL n n def main():
    n, m = LI()
    a = sorted(list(LI()))
    # 1. c以下をcに毎回置き換え.
    # for i in range(m):
    #     b, c = LI()
    #     for j in range(b):
    #         if a[j] > c:
    #             break
    #         heappushpop(a, c)
    # print(sum(a))

    # 2. 大きいcから入れていってbの累計がlen(a)になったら即終わり.
    # bc = LIR(m)
    # bc.sort(key=lambda x: x[1])
    # cnt = 0
    # for pair in bc:
    #     heappushpop(a, pair[1])
    #     cnt += pair[0]
    #     if cnt > len(a):
    #         break
    # print(sum(a))

    bc = LIR(m)
    bc.sort(key=lambda x: x[1], reverse=True)
    d = []
    i = 0
    while len(d) < n and i < len(bc):
        if bc[i][0] + len(d) < n:
            d.extend([bc[i][1]] * bc[i][0])
        else:
            d.extend([bc[i][1]] * (n - len(d)))
            break
        i += 1
    for i in range(len(d)):
        if d[i] < a[i]:
            break
        a[i] = d[i]
    print(sum(a)) main n, m = LI() n LI() LI m a = sorted(list(LI())) a sorted(list(LI())) sorted list(LI()) list LI() LI bc = LIR(m) bc LIR(m) LIR m bc.sort(key=lambda x: x[1], reverse=True) bc.sort bc sort key=lambda x: x[1] key lambda x: x[1] x[1] x 1 x reverse=True reverse True d = [] d [] i = 0 i 0 while len(d) < n and i < len(bc):
        if bc[i][0] + len(d) < n:
            d.extend([bc[i][1]] * bc[i][0])
        else:
            d.extend([bc[i][1]] * (n - len(d)))
            break
        i += 1
     len(d) < n and i < len(bc) len(d) < n len(d) len d n i < len(bc) i len(bc) len bc if bc[i][0] + len(d) < n:
            d.extend([bc[i][1]] * bc[i][0])
        else:
            d.extend([bc[i][1]] * (n - len(d)))
            break
         bc[i][0] + len(d) < n bc[i][0] + len(d) bc[i][0] [i] bc i 0 len(d) len d n d.extend([bc[i][1]] * bc[i][0]) d.extend d extend [bc[i][1]] * bc[i][0] [bc[i][1]] bc[i][1] [i] bc i 1 bc[i][0] [i] bc i 0 d.extend([bc[i][1]] * (n - len(d))) d.extend d extend [bc[i][1]] * (n - len(d)) [bc[i][1]] bc[i][1] [i] bc i 1 n - len(d) n len(d) len d break i += 1 i 1 for i in range(len(d)):
        if d[i] < a[i]:
            break
        a[i] = d[i]
     i range(len(d)) range len(d) len d if d[i] < a[i]:
            break
         d[i] < a[i] d[i] d i a[i] a i break a[i] = d[i] a[i] a i d[i] d i print(sum(a)) print sum(a) sum a if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def SRL(n): return [list(S()) for i in range(n)] def SRL(n): return [list(S()) for i in range(n)] SRL def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI() def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI() lcm def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I() def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I() LI def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]] def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]] IR mod = 10**9+7 10**9+7 mod def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2] def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2] S def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS() def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS() I def main():
    n, m = LI()
    a = sorted(list(LI()))
    # 1. c以下をcに毎回置き換え.
    # for i in range(m):
    #     b, c = LI()
    #     for j in range(b):
    #         if a[j] > c:
    #             break
    #         heappushpop(a, c)
    # print(sum(a))

    # 2. 大きいcから入れていってbの累計がlen(a)になったら即終わり.
    # bc = LIR(m)
    # bc.sort(key=lambda x: x[1])
    # cnt = 0
    # for pair in bc:
    #     heappushpop(a, pair[1])
    #     cnt += pair[0]
    #     if cnt > len(a):
    #         break
    # print(sum(a))

    bc = LIR(m)
    bc.sort(key=lambda x: x[1], reverse=True)
    d = []
    i = 0
    while len(d) < n and i < len(bc):
        if bc[i][0] + len(d) < n:
            d.extend([bc[i][1]] * bc[i][0])
        else:
            d.extend([bc[i][1]] * (n - len(d)))
            break
        i += 1
    for i in range(len(d)):
        if d[i] < a[i]:
            break
        a[i] = d[i]
    print(sum(a)) def main():
    n, m = LI()
    a = sorted(list(LI()))
    # 1. c以下をcに毎回置き換え.
    # for i in range(m):
    #     b, c = LI()
    #     for j in range(b):
    #         if a[j] > c:
    #             break
    #         heappushpop(a, c)
    # print(sum(a))

    # 2. 大きいcから入れていってbの累計がlen(a)になったら即終わり.
    # bc = LIR(m)
    # bc.sort(key=lambda x: x[1])
    # cnt = 0
    # for pair in bc:
    #     heappushpop(a, pair[1])
    #     cnt += pair[0]
    #     if cnt > len(a):
    #         break
    # print(sum(a))

    bc = LIR(m)
    bc.sort(key=lambda x: x[1], reverse=True)
    d = []
    i = 0
    while len(d) < n and i < len(bc):
        if bc[i][0] + len(d) < n:
            d.extend([bc[i][1]] * bc[i][0])
        else:
            d.extend([bc[i][1]] * (n - len(d)))
            break
        i += 1
    for i in range(len(d)):
        if d[i] < a[i]:
            break
        a[i] = d[i]
    print(sum(a)) main def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S() def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S() LS def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]] def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]] SR INF = float('inf') float('inf') INF def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]] def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]] LSR def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def] def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def] LIR
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop, heapify
import copy
import numpy as np
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


def main():
    n, m = LI()
    a = sorted(list(LI()))
    # 1. c以下をcに毎回置き換え.
    # for i in range(m):
    #     b, c = LI()
    #     for j in range(b):
    #         if a[j] > c:
    #             break
    #         heappushpop(a, c)
    # print(sum(a))

    # 2. 大きいcから入れていってbの累計がlen(a)になったら即終わり.
    # bc = LIR(m)
    # bc.sort(key=lambda x: x[1])
    # cnt = 0
    # for pair in bc:
    #     heappushpop(a, pair[1])
    #     cnt += pair[0]
    #     if cnt > len(a):
    #         break
    # print(sum(a))

    bc = LIR(m)
    bc.sort(key=lambda x: x[1], reverse=True)
    d = []
    i = 0
    while len(d) < n and i < len(bc):
        if bc[i][0] + len(d) < n:
            d.extend([bc[i][1]] * bc[i][0])
        else:
            d.extend([bc[i][1]] * (n - len(d)))
            break
        i += 1
    for i in range(len(d)):
        if d[i] < a[i]:
            break
        a[i] = d[i]
    print(sum(a))


if __name__ == "__main__":
    main()
