#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define pb         push_back

const double MID  = 1000;
const double GOAL = 2000;
const double eps  = 1e-10;
const double inf  = 1e100;

class state{
public:
  double x,v,oriv;
  int cnt;
  bool operator<(const state & a)const{
    if (!(fabs(x-a.x)<eps))return x < a.x;
    return v < a.v;
  }
};

double compute_time(double x1,double x2,double v1,double v2){
  if (x1 > x2)return inf;
  if (v1-v2<eps)return inf;
  return (x2-x1)/(v1-v2);
}

int solve(int n,vector<state>& in){
  double ans=0;
  while(n){
    double mint=inf;
    rep(i,n){
      if (fabs(in[i].x-MID)>eps)
	mint=min(mint,compute_time(in[i].x,MID,in[i].v,0));
      if (fabs(in[i].x-GOAL)>eps)
	mint=min(mint,compute_time(in[i].x,GOAL,in[i].v,0));
      REP(j,i+1,n){
	if (fabs(in[i].x-in[j].x)>eps)
	  mint=min(mint,compute_time(in[i].x,in[j].x,in[i].v,in[j].v));
      }
    }

    ans+=mint;
    assert(ans >0 && mint>0);
    rep(i,n){
      in[i].x+=in[i].v*mint;
    }

    rep(i,n){
      if (fabs(in[i].x-MID) < eps){
	in[i].v=in[i].oriv;
      }else if (fabs(in[i].x-GOAL)<eps){
	in[i].v=in[i].oriv;
	in[i].x=0;
	in[i].cnt--;
	if (in[i].cnt == 0)in[i].x = inf;
      }else {
	rep(j,n){
	  if (fabs(in[i].x-in[j].x)<eps)in[i].v=min(in[i].v,in[j].v);
	}
      }
    }


    sort(ALL(in));
    for(int i=n-1;i>=0;i--){
      if (in[i].x >2000+eps)n--;
    }
  }

  return (int)(ans+eps);
}

main(){
  int n;
  while(cin>>n && n){
    vector<state> in;
    rep(i,n){
      double t;
      int lap;
      cin>>t>>lap;
      in.pb((state){0,1000/t,1000/t,lap});
    }
    cout << solve(n,in) << endl;
  }
}