from collections import Counter

N,M=list(map(int,input().split()))

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

all_c=Counter(cards)



for i in range(M):

    time,val=list(map(int,input().split()))

    try:

        all_c[val]+=time

    except:

        all_c[val]=time



tmp=list(all_c.keys())

tmp.sort(reverse=True)

total=0

sum_time=0

for i in tmp:

    if sum_time>=N:

        break

    sum_time+=all_c[i]

    if sum_time<N:

        total+=i*all_c[i]

    else:

        total+=i*(all_c[i]+N-sum_time)

print(total)

from collections import Counter

N,M=list(map(int,input().split()))

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

all_c=Counter(cards)



for i in range(M):

    time,val=list(map(int,input().split()))

    if val in list(all_c.keys()):

        all_c[val]+=time

    else:

        all_c[val]=time

    """

    try:

        all_c[val]+=time

    except:

        all_c[val]=time

    """



tmp=list(all_c.keys())

tmp.sort(reverse=True)

total=0

sum_time=0

for i in tmp:

    if sum_time>=N:

        break

    sum_time+=all_c[i]

    if sum_time<N:

        total+=i*all_c[i]

    else:

        total+=i*(all_c[i]+N-sum_time)

print(total)

from collections import Counter

N, M = list(map(int, input().split()))
cards = list(map(int, input().split()))
all_c = Counter(cards)
for i in range(M):
    time, val = list(map(int, input().split()))
    try:
        all_c[val] += time
    except:
        all_c[val] = time
tmp = list(all_c.keys())
tmp.sort(reverse=True)
total = 0
sum_time = 0
for i in tmp:
    if sum_time >= N:
        break
    sum_time += all_c[i]
    if sum_time < N:
        total += i * all_c[i]
    else:
        total += i * (all_c[i] + N - sum_time)
print(total)

from collections import Counter

N, M = list(map(int, input().split()))
cards = list(map(int, input().split()))
all_c = Counter(cards)
for i in range(M):
    time, val = list(map(int, input().split()))
    if val in list(all_c.keys()):
        all_c[val] += time
    else:
        all_c[val] = time
    """
    try:
        all_c[val]+=time
    except:
        all_c[val]=time
    """
tmp = list(all_c.keys())
tmp.sort(reverse=True)
total = 0
sum_time = 0
for i in tmp:
    if sum_time >= N:
        break
    sum_time += all_c[i]
    if sum_time < N:
        total += i * all_c[i]
    else:
        total += i * (all_c[i] + N - sum_time)
print(total)

+    if val in list(all_c.keys()): +        all_c[val] += time +    else: +        all_c[val] = time +    """ -        all_c[val] += time +        all_c[val]+=time -        all_c[val] = time +        all_c[val]=time +    """