#include <bits/stdc++.h>
using namespace std;
struct Counter {
  static int k;
  Counter() { k++; }
  ~Counter() { k--; }
};
int Counter::k = 0;
template <typename T>
void pr(const string& name, T t) {
  cout << name << " = " << t << endl;
}
template <typename T, typename... Types>
void pr(const string& names, T t, Types... rest) {
  auto comma_pos = names.find(',');
  cout << names.substr(0, comma_pos) << " = " << t << ", ";
  auto next_name_pos = names.find_first_not_of(" \t\n", comma_pos + 1);
  pr(string(names, next_name_pos), rest...);
}
void mod(long long& a, long long b) {
  a %= b;
  if (a < 0) a += b;
}
const long long MOD = 1000000007;
long long N, T, Total;
long long P[105];
pair<long long, long long> A[105];
int main() {
  cin >> N;
  for (int i = (1); i <= (N); i++) {
    cin >> A[i].second >> A[i].first;
    Total += A[i].second;
  }
  sort(A + 1, A + N + 1);
  cin >> T;
  for (int i = (1); i <= (T); i++) cin >> P[i];
  long long factor = 1;
  long long rem = P[1];
  int i = 1;
  long long ans = 0, destroyed = 0;
  P[T + 1] = 1000000000000000ll;
  while (i <= N) {
    long long use = min(P[factor] - destroyed, A[i].second);
    ans += factor * use * A[i].first;
    destroyed += use;
    A[i].second -= use;
    if (destroyed == P[factor]) factor++;
    if (A[i].second == 0) i++;
  }
  cout << ans;
}
