#include <bits/stdc++.h>
using namespace std;
long long n, ans, m, p[105];
struct node {
  long long k, c;
} a[105];
inline bool cmp(node x, node y) { return x.c < y.c; }
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i].k >> a[i].c;
  sort(a + 1, a + 1 + n, cmp);
  cin >> m;
  for (int i = 1; i <= m; i++) cin >> p[i];
  p[m + 1] = 1e19;
  long long s = 0, f = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= a[i].k;) {
      int added = min(a[i].k - j + 1, p[f] - s);
      ans += f * a[i].c * added;
      s += added;
      while (s >= p[f] && f <= m) f++;
      j += added;
    }
  }
  cout << ans;
  return 0;
}
