import sys

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    BC = []
    for _ in range(M):
        b, c = map(int, input().split())
        BC.append((b, c))

    BC = sorted(BC, key=lambda x: -x[1])
    n = 0
    for b, c in BC:
        n += b
        A += [c] * b
        
        if n >= N:
            break

    A = sorted(A, key=lambda x: -x)
    return sum(A[:N])


if __name__ == '__main__':
    print(main()) import sys sys def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    BC = []
    for _ in range(M):
        b, c = map(int, input().split())
        BC.append((b, c))

    BC = sorted(BC, key=lambda x: -x[1])
    n = 0
    for b, c in BC:
        n += b
        A += [c] * b
        
        if n >= N:
            break

    A = sorted(A, key=lambda x: -x)
    return sum(A[:N]) main input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline 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 BC = [] BC [] for _ in range(M):
        b, c = map(int, input().split())
        BC.append((b, c))

     _ range(M) range M b, c = map(int, input().split()) b map(int, input().split()) map int input().split() ().split () input split c BC.append((b, c)) BC.append BC append (b, c) b c BC = sorted(BC, key=lambda x: -x[1]) BC sorted(BC, key=lambda x: -x[1]) sorted BC key=lambda x: -x[1] key lambda x: -x[1] -x[1] x[1] x 1 x n = 0 n 0 for b, c in BC:
        n += b
        A += [c] * b
        
        if n >= N:
            break

     b c BC n += b n b A += [c] * b A [c] * b [c] c b if n >= N:
            break

     n >= N n N break A = sorted(A, key=lambda x: -x) A sorted(A, key=lambda x: -x) sorted A key=lambda x: -x key lambda x: -x -x x x return sum(A[:N]) sum(A[:N]) sum A[:N] A :N N if __name__ == '__main__':
    print(main()) __name__ == '__main__' __name__ '__main__' print(main()) print main() main def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    BC = []
    for _ in range(M):
        b, c = map(int, input().split())
        BC.append((b, c))

    BC = sorted(BC, key=lambda x: -x[1])
    n = 0
    for b, c in BC:
        n += b
        A += [c] * b
        
        if n >= N:
            break

    A = sorted(A, key=lambda x: -x)
    return sum(A[:N]) def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    BC = []
    for _ in range(M):
        b, c = map(int, input().split())
        BC.append((b, c))

    BC = sorted(BC, key=lambda x: -x[1])
    n = 0
    for b, c in BC:
        n += b
        A += [c] * b
        
        if n >= N:
            break

    A = sorted(A, key=lambda x: -x)
    return sum(A[:N]) main
import sys

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    BC = []
    for _ in range(M):
        b, c = map(int, input().split())
        BC.append((b, c))

    BC = sorted(BC, key=lambda x: -x[1])
    n = 0
    for b, c in BC:
        n += b
        A += [c] * b
        
        if n >= N:
            break

    A = sorted(A, key=lambda x: -x)
    return sum(A[:N])


if __name__ == '__main__':
    print(main())