#include <algorithm>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <vector>

using namespace std;

// #define DEBUG 1
#define DFILE "t1.1"

int* a;
int* temp2;
struct bc_t
{
  long long int b;
  long long int c;
};
struct bc_t* bc;
struct bc_t* temp;

void merge_data(struct bc_t a[], int low, int mid, int high)
{
  int h, i, j, k;
  h = low;
  i = low;
  j = mid + 1;

  while ((h <= mid) && (j <= high)) {
    if (a[h].c <= a[j].c) {
      temp[i] = a[h];
      h++;
    } else {
      temp[i] = a[j];
      j++;
    }
    i++;
  }
  if (h > mid) {
    for (k = j; k <= high; k++) {
      temp[i] = a[k];
      i++;
    }
  } else {
    for (k = h; k <= mid; k++) {
      temp[i] = a[k];
      i++;
    }
  }
  for (k = low; k <= high; k++)
    a[k] = temp[k];
}

void merge_sort(struct bc_t data[], int left, int right)
{
  if (left < right) {
    int mid = left + (right - left) / 2;
    merge_sort(data, left, mid);
    merge_sort(data, mid + 1, right);
    merge_data(data, left, mid, right);
  }
}

void merge_data2(int a[], int low, int mid, int high)
{
  int h, i, j, k;
  h = low;
  i = low;
  j = mid + 1;

  while ((h <= mid) && (j <= high)) {
    if (a[h] <= a[j]) {
      temp2[i] = a[h];
      h++;
    } else {
      temp2[i] = a[j];
      j++;
    }
    i++;
  }
  if (h > mid) {
    for (k = j; k <= high; k++) {
      temp2[i] = a[k];
      i++;
    }
  } else {
    for (k = h; k <= mid; k++) {
      temp2[i] = a[k];
      i++;
    }
  }
  for (k = low; k <= high; k++)
    a[k] = temp2[k];
}
void merge_sort2(int data[], int left, int right)
{
  if (left < right) {
    int mid = left + (right - left) / 2;
    merge_sort2(data, left, mid);
    merge_sort2(data, mid + 1, right);
    merge_data2(data, left, mid, right);
  }
}

int main()
{
  int n, m;

#ifdef DEBUG
#define cin fin
  fstream fin(DFILE);
#endif

  cin >> n >> m;
  a = new int[n];
  temp2 = new int[n];
  bc = new struct bc_t[m];
  temp = new struct bc_t[m];
  int i, j;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  merge_sort2(a, 0, n - 1);
  for (j = 0; j < m; j++) {
    cin >> bc[j].b >> bc[j].c;
  }
  merge_sort(bc, 0, m - 1);

  // for (i = 0; i < n; i++) {
  //   cout << a[i] << " ";
  // }
  // cout << endl;
  // for (j = 0; j < m; j++) {
  //   cout << bc[j].b << " " << bc[j].c << endl;
  // }

  long long sum;
  sum = 0;
  i = n - 1;
  j = m - 1;
  int i2 = 0;
  while (i2 <= i) {
    // cout << "D0:" << i << " " << i2 << " " << j << " " << sum << endl;
    if (a[i] < bc[j].c) {
      if (i - i2 < bc[j].b) {
        sum += bc[j].c * (i - i2 + 1);
        break;
      } else {
        sum += bc[j].c * bc[j].b;
        i2 += bc[j].b;
      }
      j--;
      // cout << "D1:" << i << " " << j << " " << sum << endl;
    } else {
      sum += a[i];
      i--;
      // cout << "D2:" << i << " " << j << " " << sum << endl;
    }
  }
  // sum = bc[0].c * bc[0].b;
  // for (j = 1; j < m; j++) {
  //   cout << "D1:" << sum << " " << bc[j].c << " " << bc[j].b << " " << bc[j - 1].b << endl;
  //   sum += bc[j].c * (bc[j].b - bc[j - 1].b);
  // }
  // for (i = bc[m - 1].b; i < n; i++) {
  //   cout << "D2:" << sum << " " << a[i] << endl;
  //   sum += a[i];
  // }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 4096