#include <bits/stdc++.h>
using namespace std;
const int MAX = 109;
pair<long long, long long> a[MAX];
long long c[MAX], now, l, ans, n, t;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i].second >> a[i].first;
  sort(a, a + n);
  cin >> t;
  for (int i = 0; i < t; i++) cin >> c[i];
  c[t] = 1e17;
  for (int i = 0; i < n; i++)
    while (a[i].second > 0) {
      long long ret = min(c[l] - now, a[i].second);
      a[i].second -= ret;
      ans += ret * (l + 1) * a[i].first;
      now += ret;
      if (now >= c[l]) l++;
    }
  cout << ans << '\n';
}
