#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
bool solve() {
  int n; cin >> n;
  if(n == 0) return false;
  vector<pair<ld, ld>> p(n);
  for(int i=0;i<n;++i) {
    cin >> p[i].first >> p[i].second;
  }
  sort(p.rbegin(), p.rend());
  int ans = 0;
  vector<P> l, r;
  for(int i=0;i<n;++i) {
    int cnt = 0;
    int now = 0;
    while(cnt < p[i].second) {
      int nxtl = now + p[i].first;
      for(int j=0;j<(int)(l.size());++j) {
        if(l[j].first < now && l[j].first <= nxtl && nxtl <= l[j].second) {
          nxtl = l[j].second;
        }
      }
      l.push_back({now, nxtl});
      now = nxtl;
      int nxtr = now + p[i].first;
      for(int j=0;j<(int)(r.size());++j) {
        if(r[j].first < now && r[j].first <= nxtr && nxtr <= r[j].second) {
          nxtr = r[j].second;
        }
      }
      r.push_back({now, nxtr});
      now = nxtr;
      cnt++;
    }
    ans = max(ans, now);
  }
  cout << ans << endl;
  return true;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    if(!solve()) break;
  }
}

