#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;
int lim[100009],n,m,c,sum,cnt[100009],X;
int main(){
  cin>>n>>m>>c;
  priority_queue<P>q;
  for(int i=0;i<c;i++)scanf("%d",&lim[i]);
  for(int i=0;i<n;i++){
    int a1,a2;
    scanf("%d%d",&a1,&a2); a1--;
    q.push(P(a2,a1));
  }
  while(!q.empty()){
    P p=q.top();q.pop();
    if(lim[p.second]==cnt[p.second])continue;
    sum+=p.first;
    cnt[p.second]++;
    if(++X==m)break;
  }
  cout<<sum<<endl;
}
