#include <bits/stdc++.h>
using namespace std;
struct str {
  unsigned long long a, b;
} a[666];
bool cmp(str a, str b) { return a.b < b.b; }
int main() {
  unsigned long long n, k, t[666], ans = 0, mn = 1, cm = 0, ck = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i].a >> a[i].b;
  cin >> k;
  for (int i = 0; i < k; ++i) cin >> t[i];
  t[k] = 1000000000000000000ULL;
  sort(a, a + n, cmp);
  for (int i = 0; i < n; ++i) {
    if (t[cm] - ck >= a[i].a) {
      ck += a[i].a;
      ans += a[i].a * mn * a[i].b;
      a[i].a = 0;
    } else {
      while (666) {
        int tmp = t[cm] - ck;
        ans += tmp * mn * a[i].b;
        a[i].a -= tmp;
        ck += tmp;
        cm++;
        mn++;
        if (a[i].a <= t[cm] - ck) {
          ck += a[i].a;
          ans += a[i].a * mn * a[i].b;
          a[i].a = 0;
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
