import sys
input = sys.stdin.readline

def sol():
    N,M = list(map(int,input().split()))
    A = list(map(int,input().split()))
    tmp = sorted([list(map(int,input().split())) for _ in range(M)],key = lambda x:-x[1])
    cnt = 0
    t = []
    for a,b in tmp:
        t+=[b]*a
        cnt = cnt + a
        if cnt >=N:
            break

    A += t
    A.sort(reverse = 1)
    print(sum(A[:N]))

if __name__ == '__main__':
    sol() import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def sol():
    N,M = list(map(int,input().split()))
    A = list(map(int,input().split()))
    tmp = sorted([list(map(int,input().split())) for _ in range(M)],key = lambda x:-x[1])
    cnt = 0
    t = []
    for a,b in tmp:
        t+=[b]*a
        cnt = cnt + a
        if cnt >=N:
            break

    A += t
    A.sort(reverse = 1)
    print(sum(A[:N])) sol 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 = 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 tmp = sorted([list(map(int,input().split())) for _ in range(M)],key = lambda x:-x[1]) tmp 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 cnt = 0 cnt 0 t = [] t [] for a,b in tmp:
        t+=[b]*a
        cnt = cnt + a
        if cnt >=N:
            break

     a b tmp t+=[b]*a t [b]*a [b] b a cnt = cnt + a cnt cnt + a cnt a if cnt >=N:
            break

     cnt >=N cnt N break A += t A t A.sort(reverse = 1) A.sort A sort reverse = 1 reverse 1 print(sum(A[:N])) print sum(A[:N]) sum A[:N] A :N N if __name__ == '__main__':
    sol() __name__ == '__main__' __name__ '__main__' sol() sol input = sys.stdin.readline sys.stdin.readline input def sol():
    N,M = list(map(int,input().split()))
    A = list(map(int,input().split()))
    tmp = sorted([list(map(int,input().split())) for _ in range(M)],key = lambda x:-x[1])
    cnt = 0
    t = []
    for a,b in tmp:
        t+=[b]*a
        cnt = cnt + a
        if cnt >=N:
            break

    A += t
    A.sort(reverse = 1)
    print(sum(A[:N])) def sol():
    N,M = list(map(int,input().split()))
    A = list(map(int,input().split()))
    tmp = sorted([list(map(int,input().split())) for _ in range(M)],key = lambda x:-x[1])
    cnt = 0
    t = []
    for a,b in tmp:
        t+=[b]*a
        cnt = cnt + a
        if cnt >=N:
            break

    A += t
    A.sort(reverse = 1)
    print(sum(A[:N])) sol
import sys
input = sys.stdin.readline

def sol():
    N,M = list(map(int,input().split()))
    A = list(map(int,input().split()))
    tmp = sorted([list(map(int,input().split())) for _ in range(M)],key = lambda x:-x[1])
    cnt = 0
    t = []
    for a,b in tmp:
        t+=[b]*a
        cnt = cnt + a
        if cnt >=N:
            break

    A += t
    A.sort(reverse = 1)
    print(sum(A[:N]))

if __name__ == '__main__':
    sol()
