#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include<cassert>
#include<cstdio>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define all(n) (n).begin(),(n).end()
#define inf (1<<29)

using namespace std;
typedef pair<int,int> ii;

struct P
{
  ii time;
  bool dir;//0->上, 1->下
  P(ii time=ii(inf,inf),bool dir=false):time(time),dir(dir){}
};

int ans;
int n;

void compute(vector<vector<P> > &record,ii person)
{
  //cout << "\nperson : " << person.first << "," << person.second << endl;
  int cur = 0;
  record.push_back(vector<P>());


  rep(i,person.second*2)
    {
      bool dir = i % 2;//0->上,1->下
      int next = cur + person.first;

      //cout << "chech---------- : " << i << " | " << record.size() << endl;
      rep(j,record.size()-1)
	{
	  rep(k,record[j].size())
	    {
	      P p = record[j][k];
	      //cout << "ch(" << p.time.first << "," << p.time.second <<") dir : " <<  (dir?"↓":"↑") << "\n";
	      //if(p.time.second < cur)break;
	      if(p.dir != dir)continue;
	      if(p.time.first > cur)break;

	      if(p.time.second == next || p.time.first == cur)
		{
		  break;		  
		}
	      else if(p.time.first < next && next < p.time.second)
		{
		  next = max(p.time.second,next);
		  break;
			     //goto Skip;
		}
	    }
	}
	  //Skip:;
      //cout << "result (" << cur << "," << next << ") : " << (dir?"↓":"↑") << endl;
      record[record.size()-1].push_back(P(ii(cur,next),dir));
      cur = next;
      ans = max(ans,next);
    } 
}

int main()
{
  while(scanf("%d",&n),n)
    {
      ans = 0;
      vector<ii> info(n);
      rep(i,n)scanf("%d %d",&info[i].first,&info[i].second);
      sort(all(info),greater<ii>());

      vector<vector<P> > record;

      rep(i,n)compute(record,info[i]);

      printf("%d\n",ans);

    }
  return 0;
}