#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <cstdio>
using namespace std;

#define ALL(v) (v).begin(), (v).end()
#define REP(i,N) for(int i = 0; i < (int)(N); ++i)
double EPS = 1e-8;

struct Person {
  int id;
  int lap;
  double speed;
  double x;
  bool operator < (const Person &t) const {
    if( abs( x - t.x ) > EPS ) return x > t.x; // xÀWªå«¢Ù¤ªO
    return speed > t.speed;                    // ¯¶Èç¬¢Ù¤ªO
  }
  void print() {
    cout << "(" << id << ' ' << lap << ' ' << speed << ' ' << x << ") ";
  }
};

int main() {
  for(int N; cin >> N && N ; ) {
    int T[N], C[N];
    REP(i, N) cin >> T[i] >> C[i];

    vector<Person> v[2];
    REP(i, N) {
      v[0].push_back( (Person){i, 0, 1.0 / T[i], 0}  );
    }
    sort( ALL(v[0]) );
    int time = 0;
    for(; !v[0].empty() || !v[1].empty(); time++) {
      vector<Person> change[2];

      REP(i, v[0].size() ) {
        v[0][i].x += v[0][i].speed;
        if( i > 0 && v[0][i - 1].x < v[0][i].x ) v[0][i].x = v[0][i - 1].x;
        if( v[0][i].x >= 1.0 ) v[0][i].x = 1.0;
      }

      REP(i, v[0].size()) {
        const Person &p = v[0][i];
        if( abs( p.x - 1.0 ) < EPS ) {
          change[1].push_back( (Person){p.id, p.lap, p.speed, 0} );
        }
      }

      REP(i, v[1].size() ) {
        v[1][i].x += v[1][i].speed;
        if( i > 0 && v[1][i - 1].x < v[1][i].x ) v[1][i].x = v[1][i - 1].x;
        if( v[1][i].x >= 1.0 ) v[1][i].x = 1.0;
      }
      REP(i, v[1].size()) {
        const Person &p = v[1][i];
        if( abs( p.x - 1.0 ) < EPS ) {
          if( p.lap + 1 == C[p.id] )
            ;
          else
            change[0].push_back( (Person){p.id, p.lap + 1, p.speed, 0} );
        }
      }

      REP(i, 2) {
        while( v[i].size() && abs(v[i][0].x - 1.0) < EPS ) v[i].erase( v[i].begin() );
        sort( ALL(change[i]) );
        REP(j, change[i].size()) v[i].push_back(change[i][j]);
      }
//       REP(i, v[0].size()) v[0][i].print(); cout << endl;
//       REP(i, v[1].size()) v[1][i].print(); cout << endl;
//       cout << "----" << endl;
    }
    cout << time << endl;
  }
  return 0;
}