#include <bits/stdc++.h>
struct kc {
  int k, c;
};
bool operator<(kc l, kc r) {
  if (l.c < r.c)
    return true;
  else
    return false;
}
using namespace std;
int n, m, i;
long long b[1111], p = 0, t = 0, ans = 0;
vector<kc> v;
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    kc c;
    cin >> c.k >> c.c;
    v.push_back(c);
  }
  sort(v.begin(), v.end());
  cin >> m;
  for (i = 0; i < m; i++) cin >> b[i];
  b[m] = 1000000000000;
  for (i = 0; i < n; i++) {
    if (b[p] - t > v[i].k) {
      t += v[i].k;
      ans += (long long)v[i].k * v[i].c * (p + 1);
    } else {
      ans += (long long)(b[p] - t) * v[i].c * (p + 1);
      v[i].k -= b[p] - t;
      t += b[p] - t;
      p++;
      i--;
    }
  }
  cout << ans;
  return 0;
}
