#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
signed main(){
    int n,m,c;
    cin>>n>>m>>c;
    vi l(c);
    REP(i,c){
        cin>>l[i];
    }
    priority_queue<P> que;
    REP(i,n){
        P p;
        cin>>p.se>>p.fi;
        p.se--;
        que.push(p);
    }
    int ans=0;
    while(que.size()&&m){
        P p=que.top();que.pop();
        if(l[p.se]){
            ans+=p.fi;
            l[p.se]--;
            m--;
        }
    }
    cout<<ans<<endl;
    return 0;
}
