#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  deque<pair<long long, long long> > fig;
  for (int(i) = 0; (i) < (n); ++(i)) {
    long long a, b;
    cin >> a >> b;
    fig.push_back(make_pair(b, a));
  }
  sort(fig.begin(), fig.end());
  int t;
  cin >> t;
  vector<long long> req;
  for (int(i) = 0; (i) < (t); ++(i)) {
    long long a;
    cin >> a;
    req.push_back(a);
  }
  req.push_back(1000000000000000000LL);
  long long score = 1;
  long long dest = 0LL;
  long long ret = 0LL;
  while (true) {
    if (((int)(fig).size()) == 0LL) break;
    if (fig[0].second == 0LL) {
      fig.pop_front();
      continue;
    }
    if (dest == req[score - 1]) {
      ++score;
      continue;
    }
    long long jmldest = min(req[score - 1] - dest, fig[0].second);
    fig[0].second -= jmldest;
    dest += jmldest;
    ret += jmldest * fig[0].first * score;
  }
  cout << ret << endl;
}
