#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;

int main() {
  while(1){
    int n;
    cin>>n;
    if(!n) break;
    vector<pair<double,int>> vp;
    REP(i,n){
      double t;
      int c;
      cin>>t>>c;
      vp.emplace_back(t,c);
    }
    sort(ALL(vp));
    vector<int> rem(n);
    queue<pair<int, double>> q1, q2;
    REP(i,n) {
      double t;
      int c;
      tie(t,c) = vp[i];
      q1.emplace(i, 0);
      rem[i] = c;
    }
    int last_updated = 0;
    while(!q1.empty() || !q2.empty()) {
      bool use_q1 = q2.empty();
      if (q1.empty()) use_q1 = false;
      if (!q1.empty() && !q2.empty()) {
        int i1,i2;
        double t1,t2;
        tie(i1,t1) = q1.front();
        tie(i2,t2) = q2.front();
        if (vp[i1].first + t1 <= vp[i2].first + t2) use_q1 = true;
        else use_q1 = false;
      }
      if (!use_q1) {
        int i;
        double t;
        tie(i,t) = q2.front();
        double nt = t + vp[i].first;
        vector<int> vi(1, i);
        q2.pop();
        while(!q2.empty()) {
          int j;
          double u;
          tie(j,u) = q2.front();
          double nu = u + vp[j].first;
          if (nu > nt) break;
          vi.push_back(j);
          q2.pop();
        }
        sort(ALL(vi));
        for(int i:vi) {
          last_updated = nt;
          --rem[i];
          if (rem[i]) q1.emplace(i, nt);
        }
      } else {
        int i;
        double t;
        tie(i,t) = q1.front();
        double nt = t + vp[i].first;
        vector<int> vi(1, i);
        q1.pop();
        while(!q1.empty()) {
          int j;
          double u;
          tie(j,u) = q1.front();
          double nu = u + vp[j].first;
          if (nu > nt) break;
          vi.push_back(j);
          q1.pop();
        }
        sort(ALL(vi));
        for(int i:vi)q2.emplace(i, nt);
      }
    }
    cout << last_updated << endl;
  }
  return 0;
}