#include <bits/stdc++.h>
using namespace std;
const int MN = 100 + 10;
vector<pair<int, int> > v;
long long p[MN];
int main() {
  int n, t;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    v.push_back(make_pair(y, x));
  }
  sort(v.begin(), v.end());
  cin >> t;
  for (int i = 0; i < t; i++) cin >> p[i];
  p[t] = (1ll << 62);
  long long ans = 0;
  int pos = 0;
  long long killed = 0, k = 1;
  for (int i = 0; i < n; i++) {
    long long ost = v[i].second;
    while (ost) {
      if (killed + ost <= p[pos]) {
        ans += k * ost * v[i].first;
        killed += ost;
        ost = 0;
        if (killed == p[pos]) {
          k++;
          pos++;
        }
      } else {
        long long can = p[pos] - killed;
        ost -= can;
        ans += k * can * v[i].first;
        killed += can;
        k++;
        pos++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
