1 const maxn=50000+100;
2 type node=record
3 x,y:int64;
4 end;
5 var a,b:array[0..maxn] of node;
6 q,sta:array[0..maxn] of longint;
7 i,n,top,l,r:longint;
8 f:array[0..maxn] of int64;
9 function cmp(a,b:node):boolean;
10 begin
11 if a.x=b.x then exit(a.y<b.y) else exit(a.x<b.x);
12 end;
13 procedure sort(l,r:longint);
14 var i,j:longint;x,y:node;
15 begin
16 i:=l;j:=r;x:=a[(i+j)>>1];
17 repeat
18 while cmp(a[i],x) do inc(i);
19 while cmp(x,a[j]) do dec(j);
20 if i<=j then
21 begin
22 y:=a[i];a[i]:=a[j];a[j]:=y;
23 inc(i);dec(j);
24 end;
25 until i>j;
26 if i<r then sort(i,r);
27 if j>l then sort(l,j);
28 end;
29 procedure init;
30 begin
31 readln(n);
32 for i:=1 to n do readln(a[i].x,a[i].y);
33 sort(1,n);
34 for i:=1 to n do
35 begin
36 while (top>0) and (a[i].y>=a[sta[top]].y) do dec(top);
37 inc(top);sta[top]:=i;
38 end;
39 for i:=1 to top do b[i]:=a[sta[i]];n:=top;
40 end;
41 function k(i,j:longint):double;
42 begin
43 k:=(f[i]-f[j])/(b[j+1].y-b[i+1].y);
44 end;
45 function w(i,j:longint):int64;
46 begin
47 w:=f[j]+b[j+1].y*b[i].x
48 end;
49 procedure main;
50 begin
51 l:=0;r:=0;
52 for i:=1 to n do
53 begin
54 while (l<r) and (k(q[l+1],q[l])<b[i].x) do inc(l);
55 f[i]:=w(i,q[l]);
56 while (l<r) and (k(i,q[r])<k(q[r],q[r-1])) do dec(r);
57 inc(r);q[r]:=i;
58 end;
59 writeln(f[n]);
60 end;
61 begin
62 assign(input,‘input.txt‘);assign(output,‘output.txt‘);
63 reset(input);rewrite(output);
64 init;
65 main;
66 close(input);close(output);
67 end.