#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
struct E{
  int idx, time, lane, s;
  E() {}
  E(int i, int t, int l, int s) :
    idx(i), time(t), lane(l), s(s) {}
  bool operator < (const E& e) const {
    if(time != e.time) return time > e.time;
    if(s != e.s) return s > e.s;
    return idx > e.idx;
  }
};

int main(){
  int N;
  while(cin>>N && N){
    priority_queue<E> que;
    int rest[50] = {};
    REP(i, N){
      int t, c; cin>>t>>c;
      que.push(E(i, 0, 0, t));
      rest[i] = c;
    }
    int last[2] = {};
    while(!que.empty()){
      E e = que.top(); que.pop();
      int rt = e.time + e.s;
      int nl = e.lane ^ 1;
      if(last[nl] < rt){
        last[nl] = rt;
      }else{
        rt = last[nl];
      }
      if(nl == 0 && --rest[e.idx] == 0){
        continue;
      }
      que.push(E(e.idx, rt, nl, e.s));
    }
    cout<<last[0]<<endl;
  }
  return 0;
}