#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define _GLIBCXX_DEBUG
const int INF=1e15;

signed main(){
    int N,M;
    cin>>N>>M;
    priority_queue<int> pq;
    REP(i,N){
        int a;cin>>a;
        pq.push(a);
    }
    map<int,int>memo;
    REP(i,M){
        int a,b;cin>>a>>b;
        pq.push(b);
        memo[b]+=a-1;
    }
    int ans=0;
    REP(i,N){
        int d=pq.top();
      	ans+=d;
        if(memo[d]==0) pq.pop();
        else memo[d]--;
    }
    cout<<ans<<endl;
}