import sys
input = sys.stdin.readline
import bisect
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

minA = A[0]
Query = []
for _ in range(m):
    b,c = map(int,input().split())
    if c > minA:
        Query.append([b,c])
Query = sorted(Query, key=lambda x:(x[1], x[0]), reverse=True)

ans = 0
index = 0
for b,c in Query:
    if index >= n:
        break
    #print("----")
    cnt = 0
    Flag = True
    while Flag:
        #print(A,b,c,index)
        if A[index] < c:
            A[index] = c
            cnt += 1
            index += 1
            if (cnt >= b) or (index >= n):
                Flag = False
        else:
            Flag = False
    '''
    #A.sort()
    if A[0] >= c:
        break
    else:
        index = min(bisect.bisect_left(A,c),b)
        if index > len(A):
            ans += c * len(A)
            break
        else:
            ans += c * index
            A = A[index:]
    print(A)
    '''
print(sum(A)) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline import bisect bisect 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 A.sort() A.sort A sort minA = A[0] minA A[0] A 0 Query = [] Query [] for _ in range(m):
    b,c = map(int,input().split())
    if c > minA:
        Query.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 if c > minA:
        Query.append([b,c]) c > minA c minA Query.append([b,c]) Query.append Query append [b,c] b c Query = sorted(Query, key=lambda x:(x[1], x[0]), reverse=True) Query sorted(Query, key=lambda x:(x[1], x[0]), reverse=True) sorted Query key=lambda x:(x[1], x[0]) key lambda x:(x[1], x[0]) (x[1], x[0]) x[1] x 1 x[0] x 0 x reverse=True reverse True ans = 0 ans 0 index = 0 index 0 for b,c in Query:
    if index >= n:
        break
    #print("----")
    cnt = 0
    Flag = True
    while Flag:
        #print(A,b,c,index)
        if A[index] < c:
            A[index] = c
            cnt += 1
            index += 1
            if (cnt >= b) or (index >= n):
                Flag = False
        else:
            Flag = False
    '''
    #A.sort()
    if A[0] >= c:
        break
    else:
        index = min(bisect.bisect_left(A,c),b)
        if index > len(A):
            ans += c * len(A)
            break
        else:
            ans += c * index
            A = A[index:]
    print(A)
    ''' b c Query if index >= n:
        break
    #print("----")
     index >= n index n break cnt = 0 cnt 0 Flag = True Flag True while Flag:
        #print(A,b,c,index)
        if A[index] < c:
            A[index] = c
            cnt += 1
            index += 1
            if (cnt >= b) or (index >= n):
                Flag = False
        else:
            Flag = False
     Flag if A[index] < c:
            A[index] = c
            cnt += 1
            index += 1
            if (cnt >= b) or (index >= n):
                Flag = False
        else:
            Flag = False
     A[index] < c A[index] A index c A[index] = c A[index] A index c cnt += 1 cnt 1 index += 1 index 1 if (cnt >= b) or (index >= n):
                Flag = False
         (cnt >= b) or (index >= n) cnt >= b cnt b index >= n index n Flag = False Flag False Flag = False Flag False '''
    #A.sort()
    if A[0] >= c:
        break
    else:
        index = min(bisect.bisect_left(A,c),b)
        if index > len(A):
            ans += c * len(A)
            break
        else:
            ans += c * index
            A = A[index:]
    print(A)
    ''' print(sum(A)) print sum(A) sum A Flag = False False Flag m = map(int,input().split()) map(int,input().split()) m b,c = map(int,input().split()) map(int,input().split()) b Flag = False False Flag minA = A[0] A[0] minA Flag = True True Flag n,m = map(int,input().split()) map(int,input().split()) n c = map(int,input().split()) map(int,input().split()) c cnt += 1 1 cnt Query = sorted(Query, key=lambda x:(x[1], x[0]), reverse=True) sorted(Query, key=lambda x:(x[1], x[0]), reverse=True) Query A = list(map(int,input().split())) list(map(int,input().split())) A ans = 0 0 ans index = 0 0 index index += 1 1 index cnt = 0 0 cnt input = sys.stdin.readline sys.stdin.readline input Query = [] [] Query
import sys
input = sys.stdin.readline
import bisect
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

minA = A[0]
Query = []
for _ in range(m):
    b,c = map(int,input().split())
    if c > minA:
        Query.append([b,c])
Query = sorted(Query, key=lambda x:(x[1], x[0]), reverse=True)

ans = 0
index = 0
for b,c in Query:
    if index >= n:
        break
    #print("----")
    cnt = 0
    Flag = True
    while Flag:
        #print(A,b,c,index)
        if A[index] < c:
            A[index] = c
            cnt += 1
            index += 1
            if (cnt >= b) or (index >= n):
                Flag = False
        else:
            Flag = False
    '''
    #A.sort()
    if A[0] >= c:
        break
    else:
        index = min(bisect.bisect_left(A,c),b)
        if index > len(A):
            ans += c * len(A)
            break
        else:
            ans += c * index
            A = A[index:]
    print(A)
    '''
print(sum(A))