#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  vector<int> A(N);
  vector<pair<int, int>> BC;
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  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;
}
