#include <bits/stdc++.h>
using namespace std;
long long n, ans, m, thing[105];
struct node {
  long long k, c;
} a[105];
inline bool cmp(node x, node y) { return x.c < y.c; }
signed main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) scanf("%lld %lld", &a[i].k, &a[i].c);
  sort(a + 1, a + 1 + n, cmp);
  scanf("%lld", &m);
  for (long long i = 1; i <= m; i++) scanf("%lld", &thing[i]);
  thing[m + 1] = 1e19;
  long long vn = 0, f = 1;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= a[i].k;) {
      long long how_much = min(a[i].k - j + 1, thing[f] - vn);
      ans += f * a[i].c * how_much;
      vn += how_much;
      while (vn >= thing[f] && f <= m) f++;
      j += how_much;
    }
  }
  printf("%I64d", ans);
}
