#include<bits/stdc++.h>

using namespace std;

typedef tuple< int, int, int, int > S;

int main()
{
  int N, T[50], C[50];

  while(cin >> N, N) {
    for(int i = 0; i < N; i++) cin >> T[i] >> C[i];

    priority_queue< S, vector< S >, greater< S > > que;
    for(int i = 0; i < N; i++) que.emplace(0, T[i], C[i], 0);
    int mark[2] = {};
    while(!que.empty()) {
      int now, tim, cnt, line;
      tie(now, tim, cnt, line) = que.top();
      que.pop();
      if(cnt == 0) continue;
      line ^= 1;
      if(line == 0) --cnt;
      now = max(now + tim, mark[line]);
      mark[line] = max(mark[line], now);
      que.emplace(now, tim, cnt, line);
    }
    cout << mark[0] << endl;
  }
}