#include <bits/stdc++.h>
using namespace std;
const int dr[] = {0, -1, 0, 1, -1, 1, 1, -1};
const int dc[] = {1, 0, -1, 0, 1, 1, -1, -1};
const double eps = 1e-9;
template <class T>
void print(const vector<T> &v) {
  ostringstream os;
  for (int i = 0; i < (int)v.size(); ++i) {
    if (i) os << ' ';
    os << v[i];
  }
  cout << os.str() << endl;
}
template <class T>
int sz(const T &c) {
  return (int)c.size();
}
template <class T>
void srt(T &c) {
  sort(c.begin(), c.end());
}
template <class T>
void checkmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
void checkmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T, class U>
T cast(U x) {
  ostringstream os;
  os << x;
  T res;
  istringstream is(os.str());
  is >> res;
  return res;
}
template <class T>
vector<T> split(string s, string x = " ") {
  vector<T> res;
  for (int i = 0; i < s.size(); i++) {
    string a;
    while (i < (int)s.size() && x.find(s[i]) == string::npos) a += s[i++];
    if (!a.empty()) res.push_back(cast<T>(a));
  }
  return res;
}
template <class T>
bool inside(T r, T c, T R, T C) {
  return r >= 0 && r < R && c >= 0 && c < C;
}
int main(int argc, char *argv[]) {
  int n;
  cin >> n;
  vector<int> k(n), c(n);
  for (int i(0), _n(n); i < _n; ++i) cin >> k[i] >> c[i];
  for (int i = 0; i + 1 < n; i++) {
    for (int j = 0; j + 1 < n; j++) {
      if (c[j] > c[j + 1]) swap(c[j], c[j + 1]), swap(k[j], k[j + 1]);
    }
  }
  int t;
  cin >> t;
  vector<long long> p(t);
  for (int i(0), _n(t); i < _n; ++i) cin >> p[i];
  p.push_back(1000000000000000L);
  long long res = 0;
  int j = 0;
  long long sum = 0;
  for (int i(0), _b(sz(p) - 1); i <= _b; ++i) {
    while (j < n) {
      long long cur = min((long long)k[j], p[i] - sum);
      k[j] -= cur;
      sum += cur;
      res += cur * (i + 1) * c[j];
      if (k[j] == 0)
        ++j;
      else
        break;
    }
  }
  cout << res << endl;
  return 0;
}
