#include <bits/stdc++.h>
using namespace std;
void err(istringstream *iss) {}
template <typename T, typename... Args>
void err(istringstream *iss, const T a, const Args... args) {
  string _name;
  *iss >> _name;
  if (_name.back() == ',') _name.pop_back();
  cerr << _name << " = " << fixed << setprecision(5) << a << "; ",
      err(iss, args...);
}
const long long INF = LLONG_MAX;
const long long SZ = 4e5 + 5;
const long long mod = 1e9 + 7;
string s, s1, s2;
long long n, k, ans = 0;
long long a[SZ];
struct dat {
  long long k, c;
} fig[SZ];
bool cmp(dat x, dat y) { return (x.c < y.c); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long cs = 0, tc = 1, x, y, z, i, j, g, p, q, sum = 0, c = 0, t = 0;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> fig[i].k >> fig[i].c;
  sort(fig + 1, fig + n + 1, cmp);
  cin >> t;
  for (i = 1; i <= t; i++) cin >> a[i];
  a[t + 1] = INF;
  j = 1, c = 0;
  for (i = 1; i <= n; i++) {
    while (fig[i].k) {
      if (c + fig[i].k < a[j])
        x = fig[i].k;
      else
        x = a[j] - c;
      fig[i].k -= x;
      ans += (x * fig[i].c * j);
      c += x;
      if (fig[i].k) j++;
    }
  }
  cout << ans << "\n";
  return 0;
}
