#include <bits/stdc++.h>
using namespace std;
template <class T>
void cmax(T& a, T b) {
  a = max(a, b);
}
template <class T>
void cmin(T& a, T b) {
  a = min(a, b);
}
void _BG(const char* s) {}
template <class T, class... TT>
void _BG(const char* s, T a, TT... b) {
  for (int c = 0; *s && (c || *s != ','); ++s) {
    cerr << *s;
    for (char x : "([{") c += *s == x;
    for (char x : ")]}") c -= *s == x;
  }
  cerr << " = " << a;
  if (*s) {
    cerr << ", ";
    _BG(++s, b...);
  } else
    cerr << endl;
}
bool RD() { return 1; }
bool RD(char& a) { return scanf(" %c", &a) == 1; }
bool RD(char* a) { return scanf("%s", a) == 1; }
bool RD(double& a) { return scanf("%lf", &a) == 1; }
bool RD(int& a) { return scanf("%d", &a) == 1; }
bool RD(long long& a) { return scanf("%lld", &a) == 1; }
template <class T, class... TT>
bool RD(T& a, TT&... b) {
  return RD(a) && RD(b...);
}
void PT(const char a) { putchar(a); }
void PT(const char* a) { fputs(a, stdout); }
void PT(char* a) { fputs(a, stdout); }
void PT(const double a) { printf("%.16f", a); }
void PT(const int a) { printf("%d", a); }
void PT(const long long a) { printf("%lld", a); }
template <char s = ' ', char e = '\n'>
void PL() {
  if (e) PT(e);
}
template <char s = ' ', char e = '\n', class T, class... TT>
void PL(const T& a, const TT&... b) {
  PT(a);
  if (sizeof...(b) && s) PT(s);
  PL<s, e>(b...);
}
const int N = 106;
pair<long long, long long> p[N];
long long c[N];
int main() {
  int n;
  RD(n);
  for (int i(0); i < (n); ++i) RD(p[i].second, p[i].first);
  sort(p, p + n);
  int t;
  RD(t);
  for (int i(0); i < (t); ++i) RD(c[i]);
  for (int i((t)-1); i >= (1); --i) c[i] -= c[i - 1];
  c[t++] = 1e12;
  long long ans = 0;
  for (int i = 0, j = 0; i < t; ++i) {
    long long v = 0;
    for (; j < n; ++j) {
      long long k = min(c[i], p[j].second);
      c[i] -= k;
      p[j].second -= k;
      v += k * p[j].first;
      if (p[j].second) break;
    }
    ans += v * (i + 1);
  }
  PL(ans);
}
