### BUGGY CODE ###

#!/usr/bin/env python3
import sys

from itertools import chain


def solve(N: int, M: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    A = sorted(A)
    D = sorted(
        list(chain.from_iterable([[c] * b for b, c in zip(B, C)])),
        reverse=True)
    r = 0
    while A[r] < D[r] :
        r += 1
        if r >= len(D):
            break
    print(sum(A) + sum(D[:r]) - sum(A[:r]))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    C = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        B[i] = int(next(tokens))
        C[i] = int(next(tokens))
    solve(N, M, A, B, C)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

from itertools import chain


class BinarySearcher(object):
    def __init__(self, condition, initial_values):
        self.condition = condition
        self.initial_values = initial_values
        # all True
        if self.condition(initial_values[0]):
            self.first_solution = 0
        # all False
        elif not self.condition(initial_values[1]):
            self.first_solution = None
        else:
            self.first_solution = self.search_first_solution(
                *self.initial_values)

    def search_first_solution(self, lower, upper):
        if upper - lower <= 1:
            return condition(n)
        n = (lower + upper) // 2
        if self.condition(n):
            if not self.condition(n - 1):
                return n
            return self.search_first_solution(lower, n)
        else:
            return self.search_first_solution(n, upper)


def solve(N: int, M: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    A = sorted(A)
    bc = sorted(zip(B, C), key=lambda x: x[1], reverse=True)
    D = []
    for b, c in bc:
        D.extend([c] * b)
        if len(D) >= N:
            break
    length = min(len(A), len(D))
    r = BinarySearcher(lambda x: A[x] > D[x], (0, length - 1)).first_solution
    if r is None:
        r = length
    print(sum(A[r:]) + sum(D[:r]))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    C = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        B[i] = int(next(tokens))
        C[i] = int(next(tokens))
    solve(N, M, A, B, C)


if __name__ == '__main__':
    main()