1 #include<cstdio>
2 #include<cstring>
3 #include<algorithm>
4 #include<cmath>
5
6 #define maxn 50001
7
8 using namespace std;
9
10 struct ed{
11 int x,y;
12 }edge[maxn],E[maxn];
13
14 long long f[maxn];
15
16 double K(int x,int y){return (double)(f[y]-f[x])/(E[x+1].y-E[y+1].y);}
17
18 int que[maxn],n;
19
20 void DP()
21 {
22 int head=1,tail=1;
23 for(int i=1;i<=n;i++)
24 {
25 while(head<tail && K(que[head],que[head+1])<E[i].x)head++;
26 int sd=que[head];
27 f[i]=f[sd]+(long long)E[sd+1].y*E[i].x;
28 while(head<tail && K(que[tail],i)<K(que[tail-1],que[tail]))tail--;
29 que[++tail]=i;
30 }
31 printf("%lld",f[n]);
32 }
33
34 bool cmp(const ed A,const ed B)
35 {
36 if(A.x==B.x)return A.y<B.y;
37 return A.x<B.x;
38 }
39
40 int main()
41 {
42 int b=0;
43 scanf("%d",&n);
44 for(int i=1;i<=n;i++)
45 scanf("%d%d",&edge[i].x,&edge[i].y);
46 sort(1+edge,1+edge+n,cmp);
47 for(int i=n;i>=2;i--)
48 {
49 if(edge[i].y>=edge[i-1].y)
50 {
51 swap(edge[i],edge[i-1]);
52 n--;
53 }
54 else swap(E[++b],edge[i]);
55 }
56 swap(E[++b],edge[1]);
57 sort(1+E,1+E+n,cmp);
58 DP();
59 return 0;
60 }