#include <bits/stdc++.h>
using namespace std;
struct thing {
  long long val, sum;
} a[107];
long long n, m, ans, f[107];
bool cmp(thing p, thing q) { return p.val < q.val; }
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].sum >> a[i].val;
  }
  cin >> m;
  for (int i = 1; i <= m; i++) {
    cin >> f[i];
  }
  f[m + 1] = 0x7fffffffffffffff;
  for (int i = m; i; i--) {
    f[i] -= f[i - 1];
  }
  sort(a + 1, a + n + 1, cmp);
  long long nowf = 1;
  for (int i = 1; i <= n; i++) {
    while (a[i].sum > f[nowf]) {
      ans += a[i].val * f[nowf] * nowf;
      a[i].sum -= f[nowf];
      nowf++;
    }
    ans += a[i].sum * a[i].val * nowf;
    f[nowf] -= a[i].sum;
  }
  cout << ans;
  return 0;
}
