import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    BC = sorted([list(map(int, input().split())) for _ in range(m)], key=lambda x: -x[1])
    C = []
    for b, c in BC:
        if len(C) >= n:
            break
        C += [c] * b
    A += C
    A.sort(reverse=True)
    res = sum(A[:n])
    print(res)


if __name__ == '__main__':
    resolve() import sys sys sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline f_inf = float('inf') f_inf float('inf') float 'inf' mod = 10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 def resolve():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    BC = sorted([list(map(int, input().split())) for _ in range(m)], key=lambda x: -x[1])
    C = []
    for b, c in BC:
        if len(C) >= n:
            break
        C += [c] * b
    A += C
    A.sort(reverse=True)
    res = sum(A[:n])
    print(res) resolve 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 list(map(int, input().split())) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split BC = sorted([list(map(int, input().split())) for _ in range(m)], key=lambda x: -x[1]) BC sorted([list(map(int, input().split())) for _ in range(m)], key=lambda x: -x[1]) sorted [list(map(int, input().split())) for _ in range(m)] key=lambda x: -x[1] key lambda x: -x[1] -x[1] x[1] x 1 x C = [] C [] for b, c in BC:
        if len(C) >= n:
            break
        C += [c] * b
     b c BC if len(C) >= n:
            break
         len(C) >= n len(C) len C n break C += [c] * b C [c] * b [c] c b A += C A C A.sort(reverse=True) A.sort A sort reverse=True reverse True res = sum(A[:n]) res sum(A[:n]) sum A[:n] A :n n print(res) print res if __name__ == '__main__':
    resolve() __name__ == '__main__' __name__ '__main__' resolve() resolve f_inf = float('inf') float('inf') f_inf mod = 10 ** 9 + 7 10 ** 9 + 7 mod def resolve():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    BC = sorted([list(map(int, input().split())) for _ in range(m)], key=lambda x: -x[1])
    C = []
    for b, c in BC:
        if len(C) >= n:
            break
        C += [c] * b
    A += C
    A.sort(reverse=True)
    res = sum(A[:n])
    print(res) def resolve():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    BC = sorted([list(map(int, input().split())) for _ in range(m)], key=lambda x: -x[1])
    C = []
    for b, c in BC:
        if len(C) >= n:
            break
        C += [c] * b
    A += C
    A.sort(reverse=True)
    res = sum(A[:n])
    print(res) resolve input = sys.stdin.readline sys.stdin.readline input
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    BC = sorted([list(map(int, input().split())) for _ in range(m)], key=lambda x: -x[1])
    C = []
    for b, c in BC:
        if len(C) >= n:
            break
        C += [c] * b
    A += C
    A.sort(reverse=True)
    res = sum(A[:n])
    print(res)


if __name__ == '__main__':
    resolve()
