#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, M, C, ans;
std::vector<LL>l, c, w;
std::vector<std::pair<LL, LL>>list;

int main()
{
	in >> N >> M >> C;
	l.resize(C);
	c.resize(N), w.resize(N);
	rep(i, C) in >> l[i];
	rep(i, N) in >> c[i] >> w[i];
	rep(i, N)
	{
		list.push_back(std::make_pair(w[i], c[i]));
	}
	std::sort(list.begin(), list.end(), std::greater<std::pair<LL, LL>>());
	LL tmp = 0;
	rep(i, N)
	{
		if (tmp == M) break;
		if (l[list[i].second - 1] > 0)
		{
			--l[list[i].second - 1];
			ans += list[i].first;
			++tmp;
		}
	}
	out << ans << std::endl;
	return 0;
}
