#include <bits/stdc++.h>
#define int long long
using namespace std;

typedef pair<int,int> P;

int N;
P tc[55];

void solve(){
  
  vector<P> times[2];
  
  int ans = 0;
  
  for(int i=0;i<N;i++){
    
    int stime, gtime;
    vector<P> tmp[2];
    
    for(int j=0;j<tc[i].second*2;j++){
      
      if( j == 0 ) stime = 0, gtime = tc[i].first;
      else stime = gtime, gtime = stime + tc[i].first;
      
      for(int k=0;k<(int)times[j%2].size();k++){
	
	int start = times[j%2][k].first;
	int goal = times[j%2][k].second;
	
	if( start + 1 <= stime && gtime <= goal - 1 ) gtime = goal;
	
      }
      
      tmp[j%2].push_back( P( stime, gtime ) );
      
    }
    
    ans = max( ans, gtime );
    
    for(int j=0;j<(int)tmp[0].size();j++) times[0].push_back( tmp[0][j] );
    for(int j=0;j<(int)tmp[1].size();j++) times[1].push_back( tmp[1][j] );
    
  }
  
  cout<<ans<<endl;
  
}

signed main(){
  
  while(1){
  
    cin>>N;
    if( !N ) break;
    
    for(int i=0;i<N;i++) cin>>tc[i].first>>tc[i].second;
  
    sort( tc, tc + N, greater<P>() );
  
    solve();
  
  }
  
  return 0;
}

