def abc127d():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    d = {}
    for item in a:
        if item in d:
            d[item] += 1
        else:
            d[item] = 1
    for _ in range(m):
        b, c = map(int, input().split())
        if c in d:
            d[c] += b
        else:
            d[c] = b
    cnt = n
    ans = 0
    for k in sorted(d.keys(), reverse=True):
        v = min(cnt, d[k])
        ans += k * v
        cnt -= v
    print(ans)
abc127d() def abc127d():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    d = {}
    for item in a:
        if item in d:
            d[item] += 1
        else:
            d[item] = 1
    for _ in range(m):
        b, c = map(int, input().split())
        if c in d:
            d[c] += b
        else:
            d[c] = b
    cnt = n
    ans = 0
    for k in sorted(d.keys(), reverse=True):
        v = min(cnt, d[k])
        ans += k * v
        cnt -= v
    print(ans) abc127d 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 d = {} d {} for item in a:
        if item in d:
            d[item] += 1
        else:
            d[item] = 1
     item a if item in d:
            d[item] += 1
        else:
            d[item] = 1
     item in d item d d[item] += 1 d[item] d item 1 d[item] = 1 d[item] d item 1 for _ in range(m):
        b, c = map(int, input().split())
        if c in d:
            d[c] += b
        else:
            d[c] = b
     _ 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 in d:
            d[c] += b
        else:
            d[c] = b
     c in d c d d[c] += b d[c] d c b d[c] = b d[c] d c b cnt = n cnt n ans = 0 ans 0 for k in sorted(d.keys(), reverse=True):
        v = min(cnt, d[k])
        ans += k * v
        cnt -= v
     k sorted(d.keys(), reverse=True) sorted d.keys() d.keys d keys reverse=True reverse True v = min(cnt, d[k]) v min(cnt, d[k]) min cnt d[k] d k ans += k * v ans k * v k v cnt -= v cnt v print(ans) print ans abc127d() abc127d def abc127d():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    d = {}
    for item in a:
        if item in d:
            d[item] += 1
        else:
            d[item] = 1
    for _ in range(m):
        b, c = map(int, input().split())
        if c in d:
            d[c] += b
        else:
            d[c] = b
    cnt = n
    ans = 0
    for k in sorted(d.keys(), reverse=True):
        v = min(cnt, d[k])
        ans += k * v
        cnt -= v
    print(ans) def abc127d():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    d = {}
    for item in a:
        if item in d:
            d[item] += 1
        else:
            d[item] = 1
    for _ in range(m):
        b, c = map(int, input().split())
        if c in d:
            d[c] += b
        else:
            d[c] = b
    cnt = n
    ans = 0
    for k in sorted(d.keys(), reverse=True):
        v = min(cnt, d[k])
        ans += k * v
        cnt -= v
    print(ans) abc127d
def abc127d():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    d = {}
    for item in a:
        if item in d:
            d[item] += 1
        else:
            d[item] = 1
    for _ in range(m):
        b, c = map(int, input().split())
        if c in d:
            d[c] += b
        else:
            d[c] = b
    cnt = n
    ans = 0
    for k in sorted(d.keys(), reverse=True):
        v = min(cnt, d[k])
        ans += k * v
        cnt -= v
    print(ans)
abc127d()