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

#define int long long

signed main(){
  int n,m;
  cin >> n>> m;
  int a[n+1];
  
  vector<pair<int,int>> v;
  
  for(int i = 1;i<=n;i++)cin >> a[i];
  sort(a+1,a+n+1);
  
  for(int i = 1;i<=m;i++){
    int b,c;
    cin >> b >> c;
    v.push_back({c,b});
  }
  sort(v.rbegin(), v.rend());
  
  int ans = 0;
  
  int idx = 0;
  for(int i = 1;i<=n;i++){
    if(idx>=m)ans+=a[i];
    else{
      
      ans+=max(a[i], v[idx].first);
      v[idx].second--;
      if(v[idx].second==0)idx++;
    }
  }
  cout << ans << endl;
  return 0;
}
