#include <bits/stdc++.h>
using namespace std;
int n, id[105], m, i, j;
unsigned long long cant[105], c[105], T[105], total, sol, factor, x, llevo;
bool cmp(const int i, const int j) { return c[i] < c[j]; }
int main() {
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    cin >> cant[i] >> c[i];
    total += cant[i];
    id[i] = i;
  }
  sort(id, id + n, cmp);
  scanf("%d", &m);
  for (i = 0; i < m; i++) cin >> T[i];
  factor = 1;
  llevo = 0;
  i = 0;
  while (total > 0 && i < m) {
    if (llevo == T[i]) factor++, i++;
    j = 0;
    while (total > 0 && i < m && llevo < T[i]) {
      x = min(cant[id[j]], T[i] - llevo);
      cant[id[j]] -= x;
      total -= x;
      sol += x * factor * c[id[j]];
      llevo += x;
      j++;
    }
  }
  for (i = 0; i < n; i++) sol += cant[i] * factor * c[i];
  cout << sol << endl;
  return 0;
}
