import sys

sys.setrecursionlimit(2147483647)

INF=float("inf")

MOD=10**9+7

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

def resolve():

    from bisect import bisect_left as bisect

    n,m=list(map(int,input().split()))

    A=list(map(int,input().split()))

    A.sort()

    BC=[tuple(map(int,input().split())) for _ in range(m)]

    BC.sort(lambda x:-x[1])



    now=0

    ans=0

    for b,c in BC:

        i=bisect(A,c)

        if(i<=now): continue

        next=min(i,now+b)

        ans+=c*(next-now)

        now=next

    print((ans+sum(A[now:])))

resolve()
import sys

sys.setrecursionlimit(2147483647)

INF=float("inf")

MOD=10**9+7

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

def resolve():

    n,m=list(map(int,input().split()))

    A=list(map(int,input().split()))

    A.sort()

    BC=[list(map(int,input().split())) for _ in range(m)]

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



    now=0

    for b,c in BC:

        while(b>0 and now<n and A[now]<c):

            A[now]=c

            now+=1

            b-=1

    print((sum(A)))

resolve()
import sys

sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7
input = lambda: sys.stdin.readline().rstrip()


def resolve():
    from bisect import bisect_left as bisect

    n, m = list(map(int, input().split()))
    A = list(map(int, input().split()))
    A.sort()
    BC = [tuple(map(int, input().split())) for _ in range(m)]
    BC.sort(lambda x: -x[1])
    now = 0
    ans = 0
    for b, c in BC:
        i = bisect(A, c)
        if i <= now:
            continue
        next = min(i, now + b)
        ans += c * (next - now)
        now = next
    print((ans + sum(A[now:])))


resolve()

import sys

sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7
input = lambda: sys.stdin.readline().rstrip()


def resolve():
    n, m = list(map(int, input().split()))
    A = list(map(int, input().split()))
    A.sort()
    BC = [list(map(int, input().split())) for _ in range(m)]
    BC.sort(lambda x: x[1], reverse=1)
    now = 0
    for b, c in BC:
        while b > 0 and now < n and A[now] < c:
            A[now] = c
            now += 1
            b -= 1
    print((sum(A)))


resolve()

-    from bisect import bisect_left as bisect - -    BC = [tuple(map(int, input().split())) for _ in range(m)] -    BC.sort(lambda x: -x[1]) +    BC = [list(map(int, input().split())) for _ in range(m)] +    BC.sort(lambda x: x[1], reverse=1) -    ans = 0 -        i = bisect(A, c) -        if i <= now: -            continue -        next = min(i, now + b) -        ans += c * (next - now) -        now = next -    print((ans + sum(A[now:]))) +        while b > 0 and now < n and A[now] < c: +            A[now] = c +            now += 1 +            b -= 1 +    print((sum(A)))