#include <fstream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int main() {
    ifstream in("cond.in");
    int n;
    in >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        in >> a[i];
    }
    int m;
    in >> m;
    vector<int> b(m);
    vector<int> c(m);
    for (int i = 0; i < m; i++) {
        in >> b[i] >> c[i];
    }
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        int best = 1e9;
        for (int j = 0; j < m; j++)
            if (b[j] >= a[i] && c[j] < best)
                best = c[j];
        ans += best;
    }
    ofstream("cond.out") << ans << "\n";
}

