#include <bits/stdc++.h>
using namespace std;
const int maxn = 100;
int n, m;
pair<long long, long long> p[maxn];
long long s[maxn];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> p[i].second >> p[i].first;
  cin >> m;
  for (int i = 0; i < m; i++) cin >> s[i];
  sort(p, p + n);
  long long ans = 0, sum = 0;
  long long factor = 1;
  for (int i = 0, j = 0; i < n; i++) {
    while (j < m && sum + p[i].second >= s[j]) {
      long long tmp = s[j] - sum;
      ans += tmp * factor * p[i].first;
      p[i].second -= tmp;
      sum = s[j];
      j++;
      factor++;
    }
    ans += p[i].second * factor * p[i].first;
    sum += p[i].second;
  }
  cout << ans << endl;
}
