#include <bits/stdc++.h>
using namespace std;

struct Swimmer{
    int t, v, c;
    bool operator < (const Swimmer &s) const {return v < s.v;};
};

int N;
vector<int> T, C;

void solve(){
    deque<Swimmer> q[2];
    
    vector<Swimmer> vec;
    for(int i=0; i<N; i++){
        int v, c; cin >> v >> c;
        vec.push_back({0, v, c});
    }
    sort(vec.begin(), vec.end());
    for(int i=0; i<N; i++)
        q[0].push_back(vec[i]);
    
    int ans = 0;
    while(!q[0].empty() || !q[1].empty()){
        int cur;
        if(q[0].empty())
            cur = 1;
        else if(q[1].empty())
            cur = 0;
        else if(q[0].front().t < q[1].front().t){
            cur = 0;
        }else{
            cur = 1;
        }
        
        auto s = q[cur].front(); q[cur].pop_front();
        
        if(cur == 0){
            if(s.c == 0)
                ans = s.t;
            else{
                s.t += s.v;
                if(!q[cur^1].empty() && q[cur^1].back().t > s.t)
                    s.t = q[cur^1].back().t;
                s.c--;;
                q[cur^1].push_back(s);
            }
        }else{
            s.t += s.v;
            if(!q[cur^1].empty() && q[cur^1].back().t > s.t)
                s.t = q[cur^1].back().t;
            q[cur^1].push_back(s);
        }
        vector<Swimmer> vec;
        while(!q[cur^1].empty() && q[cur^1].back().t == s.t){
            vec.push_back(q[cur^1].back()); q[cur^1].pop_back();
        }
        sort(vec.begin(), vec.end());
        for(auto s: vec)
            q[cur^1].push_back(s);
            
    }
    cout << ans << endl;
}

int main(){
    while(cin >> N, N){
        solve();
    }
    
    return 0;
}