#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
int a[N], b[N], d[N], ps[N];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];
  for (int i = 1; i <= n; i++) ps[i] = ps[i - 1] + a[i];
  vector<int> v;
  for (int i = n; i >= 1; i--) {
    while (v.size() && b[v.back()] >= b[i]) v.pop_back();
    if (v.size())
      d[i] = v.back() - 1;
    else
      d[i] = n;
    v.push_back(i);
  }
  int s = 0, res = 0;
  for (int i = 1; i <= n; i++) {
    if (s < a[i]) {
      int tb = ps[d[i]] - ps[i - 1];
      res += tb * b[i];
      s += tb;
    }
    s -= a[i];
  }
  cout << res;
}
