#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n, m;
  cin >> n;
  cin >> m;
  int a;
  priority_queue<pair<int, int> > q;
  for (int i = 0; i < n; i++) {
    cin >> a;
    q.push(make_pair(a, 1));
  }
  long long int b, c, tmp;
  for (int i = 0; i < m; i++) {
    cin >> b;
    cin >> c;
    q.push(make_pair(c, b));
  }
  long long int sum = 0;
  long long int count = 0;
  pair<int, int> p;
  while (count < n) {
    p = q.top();
    q.pop();
    b = p.second;
    c = p.first;
    if (count + b < n) {
      sum += b * c;
      count += b;
    } else {
      sum += c * (n - count);
      count += (n - count);
      break;
    }
  }
  cout << sum;
  return 0;
}
