from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))

B = []
for i in range(M):
    B.append(list(map(int, input().split())))

B = sorted(B, key=lambda x: x[1], reverse=True)

j = 0
for b in B:
    for i in range(b[0]):
        if A[j] < b[1]:
            A[j] = b[1]
            j += 1
            if j == N:
                print(sum(A))
                sys.exit()
        else:
            print(sum(A))
            sys.exit()

print(sum(A)) from sys import stdin import sys sys import math math from functools import reduce import functools functools import itertools itertools from collections import deque,Counter,defaultdict from operator import mul import copy copy import heapq heapq sys.setrecursionlimit(10**6) sys.setrecursionlimit sys setrecursionlimit 10**6 10 6 INF = 10**18 INF 10**18 10 18 import bisect bisect import statistics statistics mod = 10**9+7 mod 10**9+7 10**9 10 9 7 N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M A = sorted(list(map(int, input().split()))) A sorted(list(map(int, input().split()))) sorted list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split B = [] B [] for i in range(M):
    B.append(list(map(int, input().split()))) i range(M) range M B.append(list(map(int, input().split()))) B.append B append list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split B = sorted(B, key=lambda x: x[1], reverse=True) B sorted(B, key=lambda x: x[1], reverse=True) sorted B key=lambda x: x[1] key lambda x: x[1] x[1] x 1 x reverse=True reverse True j = 0 j 0 for b in B:
    for i in range(b[0]):
        if A[j] < b[1]:
            A[j] = b[1]
            j += 1
            if j == N:
                print(sum(A))
                sys.exit()
        else:
            print(sum(A))
            sys.exit() b B for i in range(b[0]):
        if A[j] < b[1]:
            A[j] = b[1]
            j += 1
            if j == N:
                print(sum(A))
                sys.exit()
        else:
            print(sum(A))
            sys.exit() i range(b[0]) range b[0] b 0 if A[j] < b[1]:
            A[j] = b[1]
            j += 1
            if j == N:
                print(sum(A))
                sys.exit()
        else:
            print(sum(A))
            sys.exit() A[j] < b[1] A[j] A j b[1] b 1 A[j] = b[1] A[j] A j b[1] b 1 j += 1 j 1 if j == N:
                print(sum(A))
                sys.exit()
         j == N j N print(sum(A)) print sum(A) sum A sys.exit() sys.exit sys exit print(sum(A)) print sum(A) sum A sys.exit() sys.exit sys exit print(sum(A)) print sum(A) sum A mod = 10**9+7 10**9+7 mod N, M = map(int, input().split()) map(int, input().split()) N A = sorted(list(map(int, input().split()))) sorted(list(map(int, input().split()))) A j = 0 0 j B = sorted(B, key=lambda x: x[1], reverse=True) sorted(B, key=lambda x: x[1], reverse=True) B INF = 10**18 10**18 INF j += 1 1 j B = [] [] B M = map(int, input().split()) map(int, input().split()) M
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))

B = []
for i in range(M):
    B.append(list(map(int, input().split())))

B = sorted(B, key=lambda x: x[1], reverse=True)

j = 0
for b in B:
    for i in range(b[0]):
        if A[j] < b[1]:
            A[j] = b[1]
            j += 1
            if j == N:
                print(sum(A))
                sys.exit()
        else:
            print(sum(A))
            sys.exit()

print(sum(A))