#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;

int main(){
  int n;
  while(true) {
    cin >> n;
    if (n == 0) break;
    vector <pair<int, int> > tc;
    for (int i = 0; i < n; i++) {
      int x, y;
      cin >> x >> y;
      bool flag = false;
      for (int j = 0; j < tc.size(); j++) {
	if (tc[j].first == x) {
	  flag = true;
	  tc[j].second = max(tc[j].second, y);
	  break;
	}
      }
      if (!flag) tc.push_back(make_pair(x, y));
    }
    n = tc.size();
    sort(tc.begin(), tc.end());
    reverse(tc.begin(), tc.end());
    vector <int > leftTime[n];
    for (int i = 0; i < n; i++) leftTime[i].push_back(0);
    bool left = true;

    int total = 0;
    for (int i = 0; i < n; i++) {
      int t = tc[i].first, c = tc[i].second;
      int time = 0;
      for (int j = 0; j < 2*c; j++) {
	int bs = time;
	int bg = time+t;
	for (int k = 0; k < i; k++) {
	  for (int l = j%2; l < leftTime[k].size(); l+=2) {
	    if (l+1 >= leftTime[k].size()) break;
	    int as = leftTime[k][l];
	    int ag = leftTime[k][l+1];

	    if (bs > as && bg < ag) {
	      bg = max(ag, bg);
	    }
	  }
	}
	total = max(total, bg);
	leftTime[i].push_back(bg);
	time = bg;
      }      
    }
    cout << total << endl;
  }
}