from collections import defaultdict

def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    
    d = defaultdict(int)
    for a in A:
        d[a] += 1
    
    for m in range(M):
        b, c = map(int, input().split())
        d[c] += b
        
    d = sorted(d.items(), key=lambda x: x[0], reverse=True)

    ans = 0
    for k, v in d:
        ans += min(N, v) * k
        N -= v
        if N < 0:
          break
        
    return ans

print(solve()) from collections import defaultdict def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    
    d = defaultdict(int)
    for a in A:
        d[a] += 1
    
    for m in range(M):
        b, c = map(int, input().split())
        d[c] += b
        
    d = sorted(d.items(), key=lambda x: x[0], reverse=True)

    ans = 0
    for k, v in d:
        ans += min(N, v) * k
        N -= v
        if N < 0:
          break
        
    return ans solve 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 = defaultdict(int) d defaultdict(int) defaultdict int for a in A:
        d[a] += 1
    
     a A d[a] += 1 d[a] d a 1 for m in range(M):
        b, c = map(int, input().split())
        d[c] += b
        
     m range(M) range M b, c = map(int, input().split()) b map(int, input().split()) map int input().split() ().split () input split c d[c] += b d[c] d c b d = sorted(d.items(), key=lambda x: x[0], reverse=True) d sorted(d.items(), key=lambda x: x[0], reverse=True) sorted d.items() d.items d items key=lambda x: x[0] key lambda x: x[0] x[0] x 0 x reverse=True reverse True ans = 0 ans 0 for k, v in d:
        ans += min(N, v) * k
        N -= v
        if N < 0:
          break
        
     k v d ans += min(N, v) * k ans min(N, v) * k min(N, v) min N v k N -= v N v if N < 0:
          break
        
     N < 0 N 0 break return ans ans print(solve()) print solve() solve def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    
    d = defaultdict(int)
    for a in A:
        d[a] += 1
    
    for m in range(M):
        b, c = map(int, input().split())
        d[c] += b
        
    d = sorted(d.items(), key=lambda x: x[0], reverse=True)

    ans = 0
    for k, v in d:
        ans += min(N, v) * k
        N -= v
        if N < 0:
          break
        
    return ans def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    
    d = defaultdict(int)
    for a in A:
        d[a] += 1
    
    for m in range(M):
        b, c = map(int, input().split())
        d[c] += b
        
    d = sorted(d.items(), key=lambda x: x[0], reverse=True)

    ans = 0
    for k, v in d:
        ans += min(N, v) * k
        N -= v
        if N < 0:
          break
        
    return ans solve
from collections import defaultdict

def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    
    d = defaultdict(int)
    for a in A:
        d[a] += 1
    
    for m in range(M):
        b, c = map(int, input().split())
        d[c] += b
        
    d = sorted(d.items(), key=lambda x: x[0], reverse=True)

    ans = 0
    for k, v in d:
        ans += min(N, v) * k
        N -= v
        if N < 0:
          break
        
    return ans

print(solve())