#include <iostream>
#include <queue>

#define p pair<long long,int>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<p > que;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        que.push(p(a, 1));
    }
    for (int i = 0; i < m; i++) {
        int b, c;
        cin >> b >> c;
        que.push(p(c, b));
    }

    long long ret = 0;
    while (n > 0) {
        p x = que.top();
        que.pop();
        ret += x.first * min(x.second, n);
        n -= min(x.second, n);;
    }

    cout << ret << endl;
    return 0;
}