import sys

#import numpy as np



s2nn = lambda s: [int(c) for c in s.split(' ')]

ss2nn = lambda ss: [int(s) for s in ss]

ss2nnn = lambda ss: [s2nn(s) for s in ss]

i2s = lambda: sys.stdin.readline().rstrip()

i2n = lambda: int(i2s())

i2nn = lambda: s2nn(i2s())

ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]

ii2nn = lambda n: ss2nn(ii2ss(n))

ii2nnn = lambda n: ss2nnn(ii2ss(n))



def main():

    N, M = i2nn()

    A = i2nn()

    BC = ii2nnn(M)

    A.sort()

    BC.sort(key=lambda x: x[1])

    BC.reverse()

    #print(A)

    #print(BC)

    i = 0

    for b, c in BC:

        for _ in range(b):

            if i >= len(A) or A[i] >= c:

                break

            A[i] = c

            i += 1

    #print(A)

    print((sum(A)))



main()

import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]

ss2nn = lambda ss: [int(s) for s in ss]

ss2nnn = lambda ss: [s2nn(s) for s in ss]

i2s = lambda: sys.stdin.readline().rstrip()

i2n = lambda: int(i2s())

i2nn = lambda: s2nn(i2s())

ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]

ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]

ii2nn = lambda n: ss2nn(ii2ss(n))

ii2nnn = lambda n: ss2nnn(ii2ss(n))



def main():

    N, M = i2nn()

    A = i2nn()

    BC = ii2nnn(M)

    # 元のカード列Aを単調増加にする

    A.sort()

    # 書き換え後の値C[1:M]を単調減少にする

    BC.sort(key=lambda v: v[1])

    BC.reverse()

    # 貪欲法的に書き換える

    i = 0

    j = 0

    k = 0

    while i < N and j < M:

        b, c = BC[j]

        while i < N and k < b:

            A[i] = max(A[i], c)

            i += 1

            k += 1

        j += 1

        k = 0

    n = sum(A)

    print(n)



main()

import sys

# import numpy as np
s2nn = lambda s: [int(c) for c in s.split(" ")]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))


def main():
    N, M = i2nn()
    A = i2nn()
    BC = ii2nnn(M)
    A.sort()
    BC.sort(key=lambda x: x[1])
    BC.reverse()
    # print(A)
    # print(BC)
    i = 0
    for b, c in BC:
        for _ in range(b):
            if i >= len(A) or A[i] >= c:
                break
            A[i] = c
            i += 1
    # print(A)
    print((sum(A)))


main()

import sys

s2nn = lambda s: [int(c) for c in s.split(" ")]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))


def main():
    N, M = i2nn()
    A = i2nn()
    BC = ii2nnn(M)
    # 元のカード列Aを単調増加にする
    A.sort()
    # 書き換え後の値C[1:M]を単調減少にする
    BC.sort(key=lambda v: v[1])
    BC.reverse()
    # 貪欲法的に書き換える
    i = 0
    j = 0
    k = 0
    while i < N and j < M:
        b, c = BC[j]
        while i < N and k < b:
            A[i] = max(A[i], c)
            i += 1
            k += 1
        j += 1
        k = 0
    n = sum(A)
    print(n)


main()

-# import numpy as np +ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)] +    # 元のカード列Aを単調増加にする -    BC.sort(key=lambda x: x[1]) +    # 書き換え後の値C[1:M]を単調減少にする +    BC.sort(key=lambda v: v[1]) -    # print(A) -    # print(BC) +    # 貪欲法的に書き換える -    for b, c in BC: -        for _ in range(b): -            if i >= len(A) or A[i] >= c: -                break -            A[i] = c +    j = 0 +    k = 0 +    while i < N and j < M: +        b, c = BC[j] +        while i < N and k < b: +            A[i] = max(A[i], c) -    # print(A) -    print((sum(A))) +            k += 1 +        j += 1 +        k = 0 +    n = sum(A) +    print(n)