#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int main() {
  long long n;
  cin >> n;
  long long a[n], p[n + 1], i, ss[n + 1], ans = 0, j;
  ss[n] = 0;
  for (i = 0; i < n; i++) cin >> a[i] >> p[i];
  for (i = n - 1; i >= 0; i--) ss[i] = ss[i + 1] + a[i];
  for (i = 1; i <= 100 && n; i++) {
    for (j = 0; j < n; j++) {
      if (p[j] == i) {
        ans += (ss[j] - ss[n]) * i;
        n = j;
      }
    }
  }
  cout << ans;
  return 0;
}
