#include <bits/stdc++.h>
using namespace std;
struct tt {
  int k, c;
  bool operator<(const tt &o) const { return c < o.c; }
} z[128];
int main() {
  int n = 0, i = 0, m = 0, j = 0;
  long long p[128] = {0}, ok = 0, ans = 0;
  while (scanf("%d", &n) == 1) {
    for (i = 0; i < n; i++) {
      scanf("%d%d", &z[i].k, &z[i].c);
    }
    sort(z, z + n);
    scanf("%d", &m);
    for (i = 1; i <= m; i++) {
      scanf("%I64d", p + i);
    }
    p[0] = 0;
    p[++m] = 1000000000000000LL;
    ans = 0;
    j = 0;
    for (i = 1;; i++) {
      ok = p[i] - p[i - 1];
      for (; j < n; j++) {
        if (z[j].k <= ok) {
          ans += z[j].k * (long long)i * z[j].c;
          ok -= z[j].k;
        } else {
          ans += ok * (long long)i * z[j].c;
          z[j].k -= ok;
          break;
        }
      }
      if (j == n) {
        break;
      }
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
