#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e17;
const int MOD = 1e9 + 7;
int n, t;
pair<long long, long long> figure[100];
long long p[101];
int main() {
  scanf("%d", &n);
  for (int(i) = 0; (i) < (n); (i)++)
    scanf("%lld %lld", &figure[i].second, &figure[i].first);
  sort(figure, figure + n);
  scanf("%d", &t);
  for (int(i) = 0; (i) < (t); (i)++) scanf("%lld", &p[i]);
  p[t++] = INF;
  long long an = 0, sum = 0;
  for (int(i) = 0; (i) < (n); (i)++) {
    long long left = figure[i].second, now = sum;
    for (int(j) = 0; (j) < (t); (j)++) {
      if (p[j] > now) {
        long long add = min(left, p[j] - now);
        an += add * figure[i].first * ((long long)j + 1ll);
        left -= add;
        now += add;
      }
    }
    sum += figure[i].second;
  }
  printf("%lld\n", an);
  return 0;
}
