import sys, math
from functools import lru_cache
import datetime
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N, M = mi()
    A = list(mi())
    A.sort()
    BC = [list(mi()) for i in range(M)]
    BC.sort(reverse=True, key=lambda x: x[1])

    D = []

    for i in range(M):
        for j in range(BC[i][0]):
            D.append(BC[i][1])
            if len(D) == N:
                break
        if len(D) == N:
            break

    while len(D) < N:
        D.append(0)

    print(sum(max(A[i], D[i]) for i in range(N)))


if __name__ == '__main__':
    main() import sys, math sys math from functools import lru_cache import datetime datetime sys.setrecursionlimit(500000) sys.setrecursionlimit sys setrecursionlimit 500000 MOD = 10**9+7 MOD 10**9+7 10**9 10 9 7 def input():
    return sys.stdin.readline()[:-1] input return sys.stdin.readline()[:-1] sys.stdin.readline()[:-1] sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline :-1 -1 def mi():
    return map(int, input().split()) mi return map(int, input().split()) map(int, input().split()) map int input().split() ().split () input split def ii():
    return int(input()) ii return int(input()) int(input()) int input() input def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)] i2 list(mi()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) list(mi()) list mi() mi tmp = [list(mi()) for i in range(n)] tmp [list(mi()) for i in range(n)] list(i) for i in zip(*tmp) for i in zip(*tmp) i zip(*tmp) zip *tmp tmp for i in zip(*tmp) list(i) list i return [list(i) for i in zip(*tmp)] [list(i) for i in zip(*tmp)] n n def main():
    N, M = mi()
    A = list(mi())
    A.sort()
    BC = [list(mi()) for i in range(M)]
    BC.sort(reverse=True, key=lambda x: x[1])

    D = []

    for i in range(M):
        for j in range(BC[i][0]):
            D.append(BC[i][1])
            if len(D) == N:
                break
        if len(D) == N:
            break

    while len(D) < N:
        D.append(0)

    print(sum(max(A[i], D[i]) for i in range(N))) main N, M = mi() N mi() mi M A = list(mi()) A list(mi()) list mi() mi A.sort() A.sort A sort list(mi()) for i in range(M) for i in range(M) i range(M) range M for i in range(M) list(mi()) list mi() mi BC = [list(mi()) for i in range(M)] BC [list(mi()) for i in range(M)] BC.sort(reverse=True, key=lambda x: x[1]) BC.sort BC sort reverse=True reverse True key=lambda x: x[1] key lambda x: x[1] x[1] x 1 x D = [] D [] for i in range(M):
        for j in range(BC[i][0]):
            D.append(BC[i][1])
            if len(D) == N:
                break
        if len(D) == N:
            break

     i range(M) range M for j in range(BC[i][0]):
            D.append(BC[i][1])
            if len(D) == N:
                break
         j range(BC[i][0]) range BC[i][0] [i] BC i 0 D.append(BC[i][1]) D.append D append BC[i][1] [i] BC i 1 if len(D) == N:
                break
         len(D) == N len(D) len D N break if len(D) == N:
            break

     len(D) == N len(D) len D N break while len(D) < N:
        D.append(0)

     len(D) < N len(D) len D N D.append(0) D.append D append 0 print(sum(max(A[i], D[i]) for i in range(N))) print sum(max(A[i], D[i]) for i in range(N)) sum max(A[i], D[i]) max A[i] A i D[i] D i if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main MOD = 10**9+7 10**9+7 MOD def input():
    return sys.stdin.readline()[:-1] def input():
    return sys.stdin.readline()[:-1] input def main():
    N, M = mi()
    A = list(mi())
    A.sort()
    BC = [list(mi()) for i in range(M)]
    BC.sort(reverse=True, key=lambda x: x[1])

    D = []

    for i in range(M):
        for j in range(BC[i][0]):
            D.append(BC[i][1])
            if len(D) == N:
                break
        if len(D) == N:
            break

    while len(D) < N:
        D.append(0)

    print(sum(max(A[i], D[i]) for i in range(N))) def main():
    N, M = mi()
    A = list(mi())
    A.sort()
    BC = [list(mi()) for i in range(M)]
    BC.sort(reverse=True, key=lambda x: x[1])

    D = []

    for i in range(M):
        for j in range(BC[i][0]):
            D.append(BC[i][1])
            if len(D) == N:
                break
        if len(D) == N:
            break

    while len(D) < N:
        D.append(0)

    print(sum(max(A[i], D[i]) for i in range(N))) main def mi():
    return map(int, input().split()) def mi():
    return map(int, input().split()) mi def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)] def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)] i2 def ii():
    return int(input()) def ii():
    return int(input()) ii
import sys, math
from functools import lru_cache
import datetime
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N, M = mi()
    A = list(mi())
    A.sort()
    BC = [list(mi()) for i in range(M)]
    BC.sort(reverse=True, key=lambda x: x[1])

    D = []

    for i in range(M):
        for j in range(BC[i][0]):
            D.append(BC[i][1])
            if len(D) == N:
                break
        if len(D) == N:
            break

    while len(D) < N:
        D.append(0)

    print(sum(max(A[i], D[i]) for i in range(N)))


if __name__ == '__main__':
    main()