#include <bits/stdc++.h>
using namespace std;
struct st {
  long long c, k;
} a[100005];
long long p[100005];
bool cmp(st x, st y) { return x.c < y.c; }
int main() {
  long long n;
  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);
  long long t;
  scanf("%lld", &t);
  for (long long i = 1; i <= t; i++) scanf("%lld", &p[i]);
  p[t + 1] = 1e16;
  long long ans = 0, now = 1, last = 0;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= a[i].k;) {
      long long less = min(a[i].k - j + 1, p[now] - last);
      ans += (now * less * a[i].c);
      last += less;
      while (last >= p[now] && now <= t) now++;
      j += less;
    }
  }
  printf("%lld", ans);
  return 0;
}
