# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque

def run():
    N, M = map(int, sysread().split())
    A = list(map(int, sysread().split()))
    queue = []
    for a in A:
        heappush(queue, (-a, 1))

    for i in range(M):
        B, C = map(int, sysread().split())
        heappush(queue, (-C, B))
    total = 0
    ans = 0
    while True:
        c, b = heappop(queue)
        c *= -1
        total += b
        if total > N:
            total -= b
            break
        ans += c * b
    ans += (N - total) * c
    print(ans)

if __name__ == "__main__":
    run() import sys sys sysread = sys.stdin.buffer.readline sysread sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read from heapq import heappop, heappush sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 def run():
    N, M = map(int, sysread().split())
    A = list(map(int, sysread().split()))
    queue = []
    for a in A:
        heappush(queue, (-a, 1))

    for i in range(M):
        B, C = map(int, sysread().split())
        heappush(queue, (-C, B))
    total = 0
    ans = 0
    while True:
        c, b = heappop(queue)
        c *= -1
        total += b
        if total > N:
            total -= b
            break
        ans += c * b
    ans += (N - total) * c
    print(ans) run N, M = map(int, sysread().split()) N map(int, sysread().split()) map int sysread().split() ().split () sysread split M A = list(map(int, sysread().split())) A list(map(int, sysread().split())) list map(int, sysread().split()) map int sysread().split() ().split () sysread split queue = [] queue [] for a in A:
        heappush(queue, (-a, 1))

     a A heappush(queue, (-a, 1)) heappush queue (-a, 1) -a a 1 for i in range(M):
        B, C = map(int, sysread().split())
        heappush(queue, (-C, B))
     i range(M) range M B, C = map(int, sysread().split()) B map(int, sysread().split()) map int sysread().split() ().split () sysread split C heappush(queue, (-C, B)) heappush queue (-C, B) -C C B total = 0 total 0 ans = 0 ans 0 while True:
        c, b = heappop(queue)
        c *= -1
        total += b
        if total > N:
            total -= b
            break
        ans += c * b
     True c, b = heappop(queue) c heappop(queue) heappop queue b c *= -1 c -1 total += b total b if total > N:
            total -= b
            break
         total > N total N total -= b total b break ans += c * b ans c * b c b ans += (N - total) * c ans (N - total) * c N - total N total c print(ans) print ans if __name__ == "__main__":
    run() __name__ == "__main__" __name__ "__main__" run() run def run():
    N, M = map(int, sysread().split())
    A = list(map(int, sysread().split()))
    queue = []
    for a in A:
        heappush(queue, (-a, 1))

    for i in range(M):
        B, C = map(int, sysread().split())
        heappush(queue, (-C, B))
    total = 0
    ans = 0
    while True:
        c, b = heappop(queue)
        c *= -1
        total += b
        if total > N:
            total -= b
            break
        ans += c * b
    ans += (N - total) * c
    print(ans) def run():
    N, M = map(int, sysread().split())
    A = list(map(int, sysread().split()))
    queue = []
    for a in A:
        heappush(queue, (-a, 1))

    for i in range(M):
        B, C = map(int, sysread().split())
        heappush(queue, (-C, B))
    total = 0
    ans = 0
    while True:
        c, b = heappop(queue)
        c *= -1
        total += b
        if total > N:
            total -= b
            break
        ans += c * b
    ans += (N - total) * c
    print(ans) run read = sys.stdin.buffer.read sys.stdin.buffer.read read sysread = sys.stdin.buffer.readline sys.stdin.buffer.readline sysread
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque

def run():
    N, M = map(int, sysread().split())
    A = list(map(int, sysread().split()))
    queue = []
    for a in A:
        heappush(queue, (-a, 1))

    for i in range(M):
        B, C = map(int, sysread().split())
        heappush(queue, (-C, B))
    total = 0
    ans = 0
    while True:
        c, b = heappop(queue)
        c *= -1
        total += b
        if total > N:
            total -= b
            break
        ans += c * b
    ans += (N - total) * c
    print(ans)

if __name__ == "__main__":
    run()