#include <bits/stdc++.h>
using namespace std;
double EPS = 1e-9;
int INF = 2000000000;
long long INFF = 8000000000000000000LL;
double PI = acos(-1);
inline string IntToString(int a) {
  char x[100];
  sprintf(x, "%d", a);
  string s = x;
  return s;
}
inline int StringToInt(string a) {
  char x[100];
  int res;
  strcpy(x, a.c_str());
  sscanf(x, "%d", &res);
  return res;
}
inline string GetString(void) {
  char x[1000005];
  scanf("%s", x);
  string s = x;
  return s;
}
inline bool angka(char a) { return (a >= '0' && a <= '9'); }
inline bool kecil(char a) { return (a >= 'a' && a <= 'z'); }
inline bool besar(char a) { return (a >= 'A' && a <= 'Z'); }
inline string uppercase(string s) {
  int n = (int)s.size();
  for (int(i) = (0); (i) < (n); (i)++)
    if (kecil(s[i])) s[i] = s[i] - 'a' + 'A';
  return s;
}
inline string lowercase(string s) {
  int n = (int)s.size();
  for (int(i) = (0); (i) < (n); (i)++)
    if (besar(s[i])) s[i] = s[i] - 'A' + 'a';
  return s;
}
int n, k;
pair<int, int> data[105];
long long p[105];
long long items = 0, hitung = 0;
int batas = 0;
int ix = 1;
long long risan = 0;
long long haha = 0;
int main() {
  scanf("%d", &n);
  for (int(i) = (1); (i) <= (n); (i)++) {
    scanf("%d %d", &data[i].second, &data[i].first);
    items += (long long)data[i].second;
  }
  sort(data + 1, data + 1 + n);
  reverse(data + 1, data + 1 + n);
  scanf("%d", &k);
  for (int(i) = (1); (i) <= (k); (i)++) {
    cin >> p[i];
    if (i > 1) p[i] -= haha;
    haha += p[i];
  }
  for (int(i) = (1); (i) <= (k); (i)++) {
    if (hitung + p[i] >= items) {
      batas = i;
      p[i] = items - hitung;
      break;
    }
    hitung = hitung + p[i];
  }
  if (batas > 0)
    k = batas;
  else {
    ++k;
    p[k] = items - hitung;
  }
  for (int(i) = (k); (i) >= (1); (i)--) {
    while (p[i] > 0) {
      if (p[i] >= (long long)data[ix].second) {
        risan += ((long long)i * (long long)data[ix].second *
                  (long long)data[ix].first);
        p[i] -= (long long)data[ix].second;
        ++ix;
      } else {
        risan += ((long long)i * p[i] * (long long)data[ix].first);
        data[ix].second -= (int)p[i];
        p[i] = 0;
      }
    }
  }
  cout << risan << endl;
  return 0;
}
