#include <bits/stdc++.h>
using namespace std;
const int MaxN = 105;
long long k[MaxN], c[MaxN], p[MaxN];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d %I64d", &k[i], &c[i]);
  }
  for (int i = 1; i < n; i++)
    for (int j = i + 1; j <= n; j++)
      if (c[i] > c[j]) {
        swap(c[i], c[j]);
        swap(k[i], k[j]);
      }
  int t;
  scanf("%d", &t);
  for (int i = 1; i <= t; i++) scanf("%I64d", &p[i]);
  p[t + 1] = 1000000000000000000LL;
  long long sol = 0, d = 0, j = 1;
  for (int i = 1; i <= n;) {
    if (d + k[i] > p[j]) {
      sol += (p[j] - d) * j * c[i];
      k[i] -= (p[j] - d);
      d = p[j];
      j++;
    } else {
      sol += k[i] * j * c[i];
      d += k[i];
      i++;
    }
  }
  printf("%I64d\n", sol);
  return 0;
}
