#include <bits/stdc++.h>
using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	vector<pair<int, int>> bc;
	for (int i = 0; i < M; i++) {
		int b, c;
		cin >> b >> c;
		bc.emplace_back(c, b);
	}
	sort(bc.rbegin(), bc.rend());
	for (int i = 0, j = 0; i < M && j < N; i++) {
		int cnt = bc[i].second, val = bc[i].first;
		while (j < N && A[j] < val && cnt--) A[j++] = val;
	}
	cout << accumulate(A.begin(), A.end(), 0LL) << endl;
	return 0;
}
