def check():
    N, M = map(int, input().split())
    A = sorted([int(i) for i in input().split()])
    sousa = sorted([[int(i) for i in input().split()] for i in range(M)],
                   reverse=True, key=lambda x:x[1])
    index = 0
    for cnt, value in sousa:
        for i in range(cnt):
            if index == N:
                break
            if A[index] < value:
                A[index] = value
            else:
                return(sum(A))
            index += 1
    return(sum(A))
print(check()) def check():
    N, M = map(int, input().split())
    A = sorted([int(i) for i in input().split()])
    sousa = sorted([[int(i) for i in input().split()] for i in range(M)],
                   reverse=True, key=lambda x:x[1])
    index = 0
    for cnt, value in sousa:
        for i in range(cnt):
            if index == N:
                break
            if A[index] < value:
                A[index] = value
            else:
                return(sum(A))
            index += 1
    return(sum(A)) check N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i A = sorted([int(i) for i in input().split()]) A sorted([int(i) for i in input().split()]) sorted [int(i) for i in input().split()] [int(i) for i in input().split()] for i in range(M) for i in range(M) i range(M) range M for i in range(M) [int(i) for i in input().split()] sousa = sorted([[int(i) for i in input().split()] for i in range(M)],
                   reverse=True, key=lambda x:x[1]) sousa sorted([[int(i) for i in input().split()] for i in range(M)],
                   reverse=True, key=lambda x:x[1]) sorted [[int(i) for i in input().split()] for i in range(M)] reverse=True reverse True key=lambda x:x[1] key lambda x:x[1] x[1] x 1 x index = 0 index 0 for cnt, value in sousa:
        for i in range(cnt):
            if index == N:
                break
            if A[index] < value:
                A[index] = value
            else:
                return(sum(A))
            index += 1
     cnt value sousa for i in range(cnt):
            if index == N:
                break
            if A[index] < value:
                A[index] = value
            else:
                return(sum(A))
            index += 1
     i range(cnt) range cnt if index == N:
                break
             index == N index N break if A[index] < value:
                A[index] = value
            else:
                return(sum(A))
             A[index] < value A[index] A index value A[index] = value A[index] A index value return(sum(A)) sum(A) sum A index += 1 index 1 return(sum(A)) sum(A) sum A print(check()) print check() check def check():
    N, M = map(int, input().split())
    A = sorted([int(i) for i in input().split()])
    sousa = sorted([[int(i) for i in input().split()] for i in range(M)],
                   reverse=True, key=lambda x:x[1])
    index = 0
    for cnt, value in sousa:
        for i in range(cnt):
            if index == N:
                break
            if A[index] < value:
                A[index] = value
            else:
                return(sum(A))
            index += 1
    return(sum(A)) def check():
    N, M = map(int, input().split())
    A = sorted([int(i) for i in input().split()])
    sousa = sorted([[int(i) for i in input().split()] for i in range(M)],
                   reverse=True, key=lambda x:x[1])
    index = 0
    for cnt, value in sousa:
        for i in range(cnt):
            if index == N:
                break
            if A[index] < value:
                A[index] = value
            else:
                return(sum(A))
            index += 1
    return(sum(A)) check
def check():
    N, M = map(int, input().split())
    A = sorted([int(i) for i in input().split()])
    sousa = sorted([[int(i) for i in input().split()] for i in range(M)],
                   reverse=True, key=lambda x:x[1])
    index = 0
    for cnt, value in sousa:
        for i in range(cnt):
            if index == N:
                break
            if A[index] < value:
                A[index] = value
            else:
                return(sum(A))
            index += 1
    return(sum(A))
print(check())