#include <bits/stdc++.h>
using namespace std;
long long ans, sum, n, t, p[1100], f[1100];
struct node {
  long long k, c;
} a[110];
int 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);
  memset(p, 0x3f3f3f3f, sizeof(p));
  cin >> t;
  for (int i = 0; i < t; i++) cin >> p[i];
  int s = 0;
  for (int i = 1; i <= n; i++) {
    ans = ans + (a[i].k * a[i].c * (s + 1));
    while (sum + a[i].k > p[s]) ans = ans + (a[i].k - (p[s++] - sum)) * a[i].c;
    sum += a[i].k;
  }
  cout << ans << endl;
  return 0;
}
