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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

using pii = pair<int, int>;

int main() {
   int n, m, c;
   cin >> n >> m >> c;
   vec<int> lim(c);
   rep (i, c) { cin >> lim[i]; }
   priority_queue<pii> PQ; // value, color
   rep (i, n) {
      int c, w;
      cin >> c >> w;
      c--;
      PQ.push({w, c});
   }

   ll ans = 0;
   int i = 0;
   while (PQ.size()) {
      pii p = PQ.top(); PQ.pop();
      if (lim[p.second] > 0) {
         ans += p.first;
         lim[p.second]--;
         i++;
      }
      if (i >= m) break;
   }

   cout << ans << endl;

   return 0;
}
