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

int main(){
  int N,M;
  cin>>N>>M;
  ll a=1,i=0,b;
  vector<pair<ll,int>> C(N+M);
  for(;i<N;i++){
    cin>>b;
    C[i]={b,a};
  }
  for(;i<N+M;i++){
    cin>>a>>b;
    C[i]={b,a};
  }
  ll ans=0;
  sort(C.begin(),C.end());
  i=M+N-1;
  for(;;i--){
    if(C[i].second<=N){
      ans+=C[i].first*C[i].second;
      N-=C[i].second;
    }else{
      ans+=N*C[i].first;
      break;
    }
  }
  cout<<ans<<endl;
}