#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1e18;
int n, t;
long long num, cost, p[102], factor, prevDestroyed, ans;
vector<pair<long long, long long> > have;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> num >> cost;
    have.push_back(make_pair(cost, num));
  }
  cin >> t;
  for (int i = 0; i < t; i++) cin >> p[i];
  p[t] = INF;
  sort(have.begin(), have.end());
  for (int i = 0; i < n; i++) {
    long long haveNum = have[i].second;
    while (haveNum > 0) {
      long long canDestroy = min(p[factor] - prevDestroyed, haveNum);
      haveNum -= canDestroy;
      prevDestroyed += canDestroy;
      ans += (factor + 1) * canDestroy * have[i].first;
      if (prevDestroyed == p[factor]) factor++;
    }
  }
  cout << ans << endl;
  return 0;
}
