#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > a;
pair<long long, long long> pp;
long long n, m, ans, t, p[1000], pos, cur;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> pp.second >> pp.first;
    a.push_back(pp);
  }
  sort(a.begin(), a.end());
  cin >> t;
  for (int i = 0; i < t; i++) cin >> p[i];
  pos = 0;
  ans = 0;
  cur = 0;
  for (int i = 0; i < n; i++) {
    if (p[pos] == cur) pos++;
    if (pos == t + 1) {
      ans += a[i].second * a[i].first * pos;
      cur += a[i].second;
      continue;
    }
    while (!(cur + a[i].second <= p[pos])) {
      ans += (p[pos] - cur) * a[i].first * (pos + 1);
      a[i].second -= p[pos] - cur;
      cur += p[pos] - cur;
      pos++;
      if (pos == t + 1) break;
    }
    if (pos == t + 1) {
      ans += a[i].second * a[i].first * pos;
      cur += a[i].second;
      continue;
    }
    ans += a[i].second * a[i].first * (pos + 1);
    cur += a[i].second;
    if (cur == p[pos]) pos++;
  }
  cout << ans;
  return 0;
}
