#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:260108864")
using namespace std;
vector<pair<int, int> > mns;
vector<long long> hm;
long long k;
int main() {
  int n;
  scanf("%d", &n);
  mns.resize(n);
  for (int i(0); i <= ((int)(n)-1); ++i) {
    scanf("%d%d", &mns[i].second, &mns[i].first);
    k += mns[i].second;
  }
  int t;
  scanf("%d", &t);
  hm.resize(t);
  for (int i(0); i <= ((int)(t)-1); ++i) scanf("%I64d", &hm[i]);
  if (hm.back() != k) hm.push_back(k);
  reverse((hm).begin(), (hm).end());
  sort((mns).begin(), (mns).end());
  reverse((mns).begin(), (mns).end());
  long long now(0);
  long long ans(0);
  int curt(1);
  while (now < k) {
    if (now + mns.back().second <= hm.back()) {
      ans += mns.back().second * 1ll * mns.back().first * curt;
      now += mns.back().second;
      mns.pop_back();
    } else {
      ans += (hm.back() - now) * 1ll * mns.back().first * curt;
      mns.back() =
          make_pair(mns.back().first, mns.back().second - hm.back() + now);
      now = hm.back();
      hm.pop_back();
      ++curt;
    }
  }
  cout << ans << endl;
  return 0;
}
