void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n, m, c; rd(n, m, c);
  auto l=readln.split.to!(int[]);
  import std.typecons;
  alias Ball=Tuple!(int, "t", long, "v");
  auto bs=new Ball[](n);
  foreach(i; 0..n){
    rd(bs[i].t, bs[i].v);
    bs[i].t--;
  }

  sort!"a.v>b.v"(bs);
  long sum=0;
  foreach(b; bs)if(l[b.t]>0){
    sum+=b.v;
    l[b.t]--;
    if((--m)==0) break;
  }

  writeln(sum);
}


void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

