import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():

    n, m = LI()
    a = LI()
    lst = []

    for e in a:
        lst.append((e, 1))

    for _ in range(m):
        b, c = LI()
        lst.append((c, b))

    lst.sort(reverse=True)
    ans = 0
    cnt = 0

    for t in lst:
        time = min(t[1], n-cnt)
        ans += t[0]*time
        cnt += time
        if cnt == n:
            break
    
    print(ans)

        


main() import bisect,collections,copy,itertools,math,string bisect collections copy itertools math string import sys sys def I(): return int(sys.stdin.readline().rstrip()) I def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) LI def S(): return sys.stdin.readline().rstrip() S def LS(): return list(sys.stdin.readline().rstrip().split()) LS def main():

    n, m = LI()
    a = LI()
    lst = []

    for e in a:
        lst.append((e, 1))

    for _ in range(m):
        b, c = LI()
        lst.append((c, b))

    lst.sort(reverse=True)
    ans = 0
    cnt = 0

    for t in lst:
        time = min(t[1], n-cnt)
        ans += t[0]*time
        cnt += time
        if cnt == n:
            break
    
    print(ans)

         main n, m = LI() n LI() LI m a = LI() a LI() LI lst = [] lst [] for e in a:
        lst.append((e, 1))

     e a lst.append((e, 1)) lst.append lst append (e, 1) e 1 for _ in range(m):
        b, c = LI()
        lst.append((c, b))

     _ range(m) range m b, c = LI() b LI() LI c lst.append((c, b)) lst.append lst append (c, b) c b lst.sort(reverse=True) lst.sort lst sort reverse=True reverse True ans = 0 ans 0 cnt = 0 cnt 0 for t in lst:
        time = min(t[1], n-cnt)
        ans += t[0]*time
        cnt += time
        if cnt == n:
            break
    
     t lst time = min(t[1], n-cnt) time min(t[1], n-cnt) min t[1] t 1 n-cnt n cnt ans += t[0]*time ans t[0]*time t[0] t 0 time cnt += time cnt time if cnt == n:
            break
    
     cnt == n cnt n break print(ans) print ans main() main def I(): return int(sys.stdin.readline().rstrip()) def I(): return int(sys.stdin.readline().rstrip()) I def main():

    n, m = LI()
    a = LI()
    lst = []

    for e in a:
        lst.append((e, 1))

    for _ in range(m):
        b, c = LI()
        lst.append((c, b))

    lst.sort(reverse=True)
    ans = 0
    cnt = 0

    for t in lst:
        time = min(t[1], n-cnt)
        ans += t[0]*time
        cnt += time
        if cnt == n:
            break
    
    print(ans)

         def main():

    n, m = LI()
    a = LI()
    lst = []

    for e in a:
        lst.append((e, 1))

    for _ in range(m):
        b, c = LI()
        lst.append((c, b))

    lst.sort(reverse=True)
    ans = 0
    cnt = 0

    for t in lst:
        time = min(t[1], n-cnt)
        ans += t[0]*time
        cnt += time
        if cnt == n:
            break
    
    print(ans)

         main def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) LI def S(): return sys.stdin.readline().rstrip() def S(): return sys.stdin.readline().rstrip() S def LS(): return list(sys.stdin.readline().rstrip().split()) def LS(): return list(sys.stdin.readline().rstrip().split()) LS
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():

    n, m = LI()
    a = LI()
    lst = []

    for e in a:
        lst.append((e, 1))

    for _ in range(m):
        b, c = LI()
        lst.append((c, b))

    lst.sort(reverse=True)
    ans = 0
    cnt = 0

    for t in lst:
        time = min(t[1], n-cnt)
        ans += t[0]*time
        cnt += time
        if cnt == n:
            break
    
    print(ans)

        


main()
