#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pi = pair<ll, ll>;
using pll = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f;
constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
template <class RIt>
void dbarr(RIt frs, RIt lst) {
  cerr << "arr: ";
  for (ll i = 0; i < (ll)(lst - frs); i++)
    cerr << frs[i] << " \n"[i == (ll)(lst - frs) - 1];
}
signed main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);
  ll n;
  cin >> n;
  vector<pi> a;
  for (ll i = 0; i < n; i++) {
    ll k, c;
    cin >> k >> c;
    a.emplace_back(k, c);
  }
  ll t;
  cin >> t;
  vector<ll> p;
  ll ptr = 0;
  for (ll i = 0; i < t; i++) {
    ll x;
    cin >> x;
    p.emplace_back(x);
  }
  p.emplace_back(LLINF);
  sort(begin(a), end(a), [](pi& a, pi& b) { return a.second < b.second; });
  ll cur = p[ptr], ans = 0;
  ll i = 0;
  while (i < n) {
    if (a[i].first <= cur) {
      ans += 1ll * a[i].first * (ptr + 1) * a[i].second;
      cur -= a[i].first;
      i++;
    } else {
      ans += 1ll * cur * (ptr + 1) * a[i].second;
      a[i].first -= cur;
      ptr++;
      cur = p[ptr] - p[ptr - 1];
    }
  }
  cout << ans << "\n";
}
