#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const int INF = (int)1e9 + 7;
const long long LINF = (long long)9e18 + 7;
const long long P1 = 353251;
const long long P2 = 239017;
const long long MOD = 1e9 + 7;
const long long MOD1 = 1e9 + 7;
const long long MOD2 = 1e9 + 9;
int n, m;
long long ans = 0;
pair<long long, long long> a[107];
long long t[107];
const bool is_testing = 0;
int main() {
  srand('D' + 'E' + 'N' + 'I' + 'S' + 'S' + 'O' + 'N' + time(NULL));
  if (is_testing) {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  } else {
  }
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i].second >> a[i].first;
  cin >> m;
  for (int i = 0; i < m; i++) cin >> t[i];
  long long sum = t[0];
  for (int i = 1; i < m; i++) {
    t[i] -= sum;
    sum += t[i];
  }
  t[m] = LINF;
  sort(a, a + n);
  int uk = 0;
  for (int i = 0; i < n; i++) {
    long long now = a[i].second;
    while (now) {
      if (now < t[uk]) {
        ans += now * a[i].first * (uk + 1);
        t[uk] -= now;
        now = 0;
      } else {
        now -= t[uk];
        ans += t[uk] * a[i].first * (uk + 1);
        uk++;
      }
    }
  }
  cout << ans;
}
