#import math
#import itertools
#import numpy as np
#from collections import deque


INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    n,m=INTM()
    A=LIST()
    bcs=[]
    for i in range(m):
        temp=LIST()
        bcs.append(temp)
    A=sorted(A)
    bcs=sorted(bcs, key=lambda x: x[1], reverse=True)
    itr=-1
    flg=False
    #print(A)
    for b,c in bcs:
        if itr+b>n-1:
            flg=True
        if flg:
            for i in range(itr+1,n):
                if A[i]<c:
                    A[i]=c
                else:
                    itr=10**9
                    break
        else:
            if A[itr+b]<c:
                A[itr+1:itr+b+1]=[c]*b
            else:
                for i in range(itr+1,itr+b+1):
                    if A[i]<c:
                        A[i]=c
                    else:
                        itr=10**9
                        break

        itr+=b

        if itr>n-1:
            break
    print(sum(A))
    #print(A)

    


if __name__=='__main__':
    do() INT = lambda: int(input()) INT lambda: int(input()) int(input()) int input() input INTM = lambda: map(int,input().split()) INTM lambda: map(int,input().split()) map(int,input().split()) map int input().split() ().split () input split STRM = lambda: map(str,input().split()) STRM lambda: map(str,input().split()) map(str,input().split()) map str input().split() ().split () input split STR = lambda: str(input()) STR lambda: str(input()) str(input()) str input() input LIST = lambda: list(map(int,input().split())) LIST lambda: list(map(int,input().split())) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split LISTS = lambda: list(map(str,input().split())) LISTS lambda: list(map(str,input().split())) list(map(str,input().split())) list map(str,input().split()) map str input().split() ().split () input split def do():
    n,m=INTM()
    A=LIST()
    bcs=[]
    for i in range(m):
        temp=LIST()
        bcs.append(temp)
    A=sorted(A)
    bcs=sorted(bcs, key=lambda x: x[1], reverse=True)
    itr=-1
    flg=False
    #print(A)
    for b,c in bcs:
        if itr+b>n-1:
            flg=True
        if flg:
            for i in range(itr+1,n):
                if A[i]<c:
                    A[i]=c
                else:
                    itr=10**9
                    break
        else:
            if A[itr+b]<c:
                A[itr+1:itr+b+1]=[c]*b
            else:
                for i in range(itr+1,itr+b+1):
                    if A[i]<c:
                        A[i]=c
                    else:
                        itr=10**9
                        break

        itr+=b

        if itr>n-1:
            break
    print(sum(A))
    #print(A)

     do n,m=INTM() n INTM() INTM m A=LIST() A LIST() LIST bcs=[] bcs [] for i in range(m):
        temp=LIST()
        bcs.append(temp)
     i range(m) range m temp=LIST() temp LIST() LIST bcs.append(temp) bcs.append bcs append temp A=sorted(A) A sorted(A) sorted A bcs=sorted(bcs, key=lambda x: x[1], reverse=True) bcs sorted(bcs, key=lambda x: x[1], reverse=True) sorted bcs key=lambda x: x[1] key lambda x: x[1] x[1] x 1 x reverse=True reverse True itr=-1 itr -1 flg=False flg False for b,c in bcs:
        if itr+b>n-1:
            flg=True
        if flg:
            for i in range(itr+1,n):
                if A[i]<c:
                    A[i]=c
                else:
                    itr=10**9
                    break
        else:
            if A[itr+b]<c:
                A[itr+1:itr+b+1]=[c]*b
            else:
                for i in range(itr+1,itr+b+1):
                    if A[i]<c:
                        A[i]=c
                    else:
                        itr=10**9
                        break

        itr+=b

        if itr>n-1:
            break
     b c bcs if itr+b>n-1:
            flg=True
         itr+b>n-1 itr+b itr b n-1 n 1 flg=True flg True if flg:
            for i in range(itr+1,n):
                if A[i]<c:
                    A[i]=c
                else:
                    itr=10**9
                    break
        else:
            if A[itr+b]<c:
                A[itr+1:itr+b+1]=[c]*b
            else:
                for i in range(itr+1,itr+b+1):
                    if A[i]<c:
                        A[i]=c
                    else:
                        itr=10**9
                        break

         flg for i in range(itr+1,n):
                if A[i]<c:
                    A[i]=c
                else:
                    itr=10**9
                    break
         i range(itr+1,n) range itr+1 itr 1 n if A[i]<c:
                    A[i]=c
                else:
                    itr=10**9
                    break
         A[i]<c A[i] A i c A[i]=c A[i] A i c itr=10**9 itr 10**9 10 9 break if A[itr+b]<c:
                A[itr+1:itr+b+1]=[c]*b
            else:
                for i in range(itr+1,itr+b+1):
                    if A[i]<c:
                        A[i]=c
                    else:
                        itr=10**9
                        break

         A[itr+b]<c A[itr+b] A itr+b itr b c A[itr+1:itr+b+1]=[c]*b A[itr+1:itr+b+1] A itr+1:itr+b+1 itr+1 itr 1 itr+b+1 itr+b itr b 1 [c]*b [c] c b for i in range(itr+1,itr+b+1):
                    if A[i]<c:
                        A[i]=c
                    else:
                        itr=10**9
                        break

         i range(itr+1,itr+b+1) range itr+1 itr 1 itr+b+1 itr+b itr b 1 if A[i]<c:
                        A[i]=c
                    else:
                        itr=10**9
                        break

         A[i]<c A[i] A i c A[i]=c A[i] A i c itr=10**9 itr 10**9 10 9 break itr+=b itr b if itr>n-1:
            break
     itr>n-1 itr n-1 n 1 break print(sum(A)) print sum(A) sum A if __name__=='__main__':
    do() __name__=='__main__' __name__ '__main__' do() do LISTS = lambda: list(map(str,input().split())) lambda: list(map(str,input().split())) LISTS INT = lambda: int(input()) lambda: int(input()) INT STRM = lambda: map(str,input().split()) lambda: map(str,input().split()) STRM STR = lambda: str(input()) lambda: str(input()) STR LIST = lambda: list(map(int,input().split())) lambda: list(map(int,input().split())) LIST INTM = lambda: map(int,input().split()) lambda: map(int,input().split()) INTM def do():
    n,m=INTM()
    A=LIST()
    bcs=[]
    for i in range(m):
        temp=LIST()
        bcs.append(temp)
    A=sorted(A)
    bcs=sorted(bcs, key=lambda x: x[1], reverse=True)
    itr=-1
    flg=False
    #print(A)
    for b,c in bcs:
        if itr+b>n-1:
            flg=True
        if flg:
            for i in range(itr+1,n):
                if A[i]<c:
                    A[i]=c
                else:
                    itr=10**9
                    break
        else:
            if A[itr+b]<c:
                A[itr+1:itr+b+1]=[c]*b
            else:
                for i in range(itr+1,itr+b+1):
                    if A[i]<c:
                        A[i]=c
                    else:
                        itr=10**9
                        break

        itr+=b

        if itr>n-1:
            break
    print(sum(A))
    #print(A)

     def do():
    n,m=INTM()
    A=LIST()
    bcs=[]
    for i in range(m):
        temp=LIST()
        bcs.append(temp)
    A=sorted(A)
    bcs=sorted(bcs, key=lambda x: x[1], reverse=True)
    itr=-1
    flg=False
    #print(A)
    for b,c in bcs:
        if itr+b>n-1:
            flg=True
        if flg:
            for i in range(itr+1,n):
                if A[i]<c:
                    A[i]=c
                else:
                    itr=10**9
                    break
        else:
            if A[itr+b]<c:
                A[itr+1:itr+b+1]=[c]*b
            else:
                for i in range(itr+1,itr+b+1):
                    if A[i]<c:
                        A[i]=c
                    else:
                        itr=10**9
                        break

        itr+=b

        if itr>n-1:
            break
    print(sum(A))
    #print(A)

     do
#import math
#import itertools
#import numpy as np
#from collections import deque


INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    n,m=INTM()
    A=LIST()
    bcs=[]
    for i in range(m):
        temp=LIST()
        bcs.append(temp)
    A=sorted(A)
    bcs=sorted(bcs, key=lambda x: x[1], reverse=True)
    itr=-1
    flg=False
    #print(A)
    for b,c in bcs:
        if itr+b>n-1:
            flg=True
        if flg:
            for i in range(itr+1,n):
                if A[i]<c:
                    A[i]=c
                else:
                    itr=10**9
                    break
        else:
            if A[itr+b]<c:
                A[itr+1:itr+b+1]=[c]*b
            else:
                for i in range(itr+1,itr+b+1):
                    if A[i]<c:
                        A[i]=c
                    else:
                        itr=10**9
                        break

        itr+=b

        if itr>n-1:
            break
    print(sum(A))
    #print(A)

    


if __name__=='__main__':
    do()