#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const double PI = 3.14159265358;
const int inf = (int)1e9;
const int MAX_N = 1000;
long long n, t;
long long k[111], c[111], p[111];
vector<pair<long long, long long> > v;
void cal() {
  long long ans = 0;
  long long cur = 0;
  long long f = 1;
  int i = 0;
  int j = 0;
  long long rem = v[i].second;
  while (i < ((int)v.size())) {
    long long mini = min(rem, p[j] - cur);
    ans += mini * f * v[i].first;
    cur += mini;
    rem -= mini;
    if (cur == p[j]) j++, f++;
    if (rem == 0) {
      i++;
      if (i == ((int)v.size())) break;
      rem = v[i].second;
    }
  }
  cout << ans << endl;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> k[i] >> c[i];
    v.push_back(pair<long long, long long>(c[i], k[i]));
  }
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> p[i];
  }
  p[t] = (long long)1e18;
  sort(v.begin(), v.end());
  cal();
  return 0;
}
