#include <bits/stdc++.h>
using namespace std;
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return __builtin_popcount(s);
}
const long double PI = 2 * acos(0.0);
const long double eps = 1e-15;
const int infi = 1e9;
const long long Linfi = (long long)1e18;
int n, sum[100100];
vector<pair<int, int> > v;
void solve() {
  cin >> n;
  int a, p;
  sum[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a >> p;
    sum[i] = sum[i - 1] + a;
    v.push_back(make_pair(p, i));
  }
  sort(v.begin(), v.end());
  int pos = 0, temp = n + 1, ans = 0;
  while (true) {
    int t = v[pos].second;
    if (t < temp) {
      ans += (sum[temp - 1] - sum[t - 1]) * v[pos].first;
      temp = t;
      if (temp == 1) {
        cout << ans << endl;
        return;
      }
    }
    ++pos;
  }
}
int main() {
  solve();
  return 0;
}
