#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n;
  cin >> n;
  long long a[n], p[n];
  long long meats[n];
  long long remeats[n];
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> p[i];
    sum += a[i];
    meats[i] = sum;
  }
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      remeats[i] = sum;
    } else {
      remeats[i] = sum - meats[i - 1];
    }
  }
  long long minimal = INT_MAX;
  long long price, pr;
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      price = remeats[i] * p[i];
    } else {
      price = price - remeats[i] * (pr - p[i]);
    }
    if (minimal > price) {
      minimal = price;
      pr = p[i];
    }
    price = minimal;
  }
  cout << minimal << endl;
  return 0;
}
