#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
using namespace std;
const int maxn=50005;
struct node{
int w,h;
}data;
int main(){
int n,ans,totalw,curarea;
while(scanf("%d",&n)&&n!=-1){
stack<node>sta;
ans=-1;
for(int i=0;i<n;i++){
scanf("%d %d",&data.w,&data.h);
if(sta.empty()||data.h>sta.top().h){//如果当前元素的高大于栈顶元素的高,加入栈
sta.push(data);
}
else{//如果当前元素的高小于等于栈顶元素的高
totalw=0;
curarea=0;
while(sta.size()&&sta.top().h>data.h){//如果栈不为空且栈顶元素大于当前元素的高
totalw+=sta.top().w;//总宽增加
curarea=totalw*sta.top().h;//当前面积为总宽乘以栈顶的高度
if(curarea>ans){//储存最大值
ans=curarea;
}
sta.pop();
}
totalw+=data.w;//栈中加入一个新元素,高为当前高度,宽为弹出总素的总宽加上当前元素的宽
data.w=totalw;
sta.push(data);
}
}
totalw=0;
curarea=0;
while(sta.size()){//最后栈中元素必定是按高递增的
totalw+=sta.top().w;
curarea=totalw*sta.top().h;
if(curarea>ans){
ans=curarea;
}
sta.pop();
}
printf("%d\n",ans);
}
return 0;
}