#include <bits/stdc++.h>

using namespace std;

struct Swimmer {
  int v, lap, next;
  Swimmer(){}
  Swimmer(int v, int lap, int next):v(v), lap(lap), next(next){}
  bool operator < (const Swimmer& s) const {
    return v < s.v;
  }
};

int N;
vector<Swimmer> swimmer;
queue<Swimmer> lane[2];

int main() {
  while(cin >> N, N) {
    swimmer.clear();
    for(int i = 0; i < N; i++) {
      int t, c;
      cin >> t >> c;
      swimmer.emplace_back(t, c, t);
    }
    sort(begin(swimmer), end(swimmer));
    for(auto&& s : swimmer) lane[0].push(s);
    int ans = 0;
    while(!lane[0].empty() || !lane[1].empty()) {
      bool id = lane[0].empty();
      if(!id && !lane[1].empty()) id = lane[1].front().next < lane[0].front().next;
      vector<Swimmer> vec;
      vec.push_back(lane[id].front());
      int tmp = vec[0].next;
      lane[id].pop();
      while(!lane[id].empty() && tmp >= lane[id].front().next) {
	vec.push_back(lane[id].front());
	lane[id].pop();
      }
      for(auto&& s : vec) {
	s.next = tmp+s.v;
	s.lap -= id;
	if(s.lap == 0) ans = max(ans, tmp);
      }
      sort(begin(vec), end(vec));
      for(auto&& s : vec) {
	if(s.lap > 0) lane[1-id].push(s);
      }
    }
    cout << ans << endl;
  }

  return 0;
}