RT。
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define ri register long long
#define inf 0x3f3f3f3f
long long a,b,m,n,cnt;
long long ans;
pair<long long,long long>pit[50005],tb[100001];
struct TB
{
#define N 50005
long long bg,ed;
bool op;
pair<long long,long long>nm[N];
il TB(bool x=false)
{
bg=1;
ed=0;
op=x;
}
il long double got1(pair<long long,long long> x,pair<long long,long long> y)
{
long long rn=y.second-x.second;
if(fabs(y.first-x.first)<1e-9)
{
return (y.second-x.second)*1e9;
}
rn/=y.first-x.first;
return rn;
}
il long long got2(pair<long long,long long> x,pair<long long,long long> y)
{
return sqrt(((x.first-y.first)*(x.first-y.first))+((x.second-y.second)*(x.second-y.second)));
}
il bool check(pair<long long,long long> x,pair<long long,long long> y,pair<long long,long long> z)
{
if(fabs(got1(x,y)-got1(y,z))<1e-9)
{
return true;
}
if((got1(x,y)>got1(y,z))^op)
{
return true;
}
else
{
return false;
}
}
il void push_back(pair<long long,long long> x)
{
while(bg<ed&&!check(nm[ed-1],nm[ed],x))
{
ed--;
}
ed++;
nm[ed]=x;
}
#undef N
}que[2]{(false),(true)};
struct vecter
{
long long xx,yy;
il vecter(pair<long long,long long>x={0,0},pair<long long,long long>y={0,0})
{
xx=y.first-x.first;
yy=y.second-x.second;
}
long long operator *(const vecter &A)
{
return max(xx*A.yy-A.xx*yy,A.xx*yy-xx*A.yy);
}
};
int main()
{
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
scanf("%lld",&a);
for(ri i=1;i<=a;i++)
{
scanf("%lld%lld",&pit[i].first,&pit[i].second);
}
if(a==2)
{
printf("%lld",(long long)(pit[1].first-pit[2].first)*(pit[1].first-pit[2].first)+(pit[1].second-pit[2].second)*(pit[1].second-pit[2].second));
return 0;
}
sort(pit+1,pit+1+a);
que[1].push_back(pit[1]);
for(ri i=1;i<=a;i++)
{
if(pit[i].first!=pit[1].first)
{
que[0].push_back(pit[i-1]);
m=i;
break;
}
cnt++;
tb[cnt]=pit[i];
}
for(ri i=a;i>=1;i--)
{
if(pit[i].first!=pit[a].first)
{
n=i;
break;
}
}
if(!m)
{
printf("%lld",(long long)(pit[a].second-pit[1].second)*(pit[a].second-pit[1].second));
return 0;
}
for(ri i=m;i<=n;i++)
{
que[0].push_back(pit[i]);
que[1].push_back(pit[i]);
}
que[0].push_back(pit[a]);
que[1].push_back(pit[n+1]);
for(ri i=que[0].bg+1;i<=que[0].ed-1;i++)
{
cnt++;
tb[cnt]=que[0].nm[i];
}
for(ri i=a;i>n;i--)
{
cnt++;
tb[cnt]=pit[i];
}
for(ri i=que[1].ed-1;i>=que[1].bg+1;i--)
{
cnt++;
tb[cnt]=que[1].nm[i];
}
for(ri i=1;i<=cnt;i++)
{
tb[cnt+i]=tb[i];
}
ri bg=3,ed=cnt;
for(ri i=1;i<=cnt;i++)
{
register long long num=-inf;
ri j;
for(j=bg;j<=ed;j++)
{
vecter h(tb[j],tb[i]),k(tb[j],tb[i+1]);
// printf("%.2Lf\n",h*k);
if(num>=h*k)
{
j--;
break;
}
num=h*k;
}
j=max(j,bg);
j=min(j,ed);
ans=max(ans,(long long)(tb[j].first-tb[i].first)*(tb[j].first-tb[i].first)+(tb[j].second-tb[i].second)*(tb[j].second-tb[i].second));
ans=max(ans,(long long)(tb[j].first-tb[i+1].first)*(tb[j].first-tb[i+1].first)+(tb[j].second-tb[i+1].second)*(tb[j].second-tb[i+1].second));
bg=j;
ed=j+cnt-1;
if(bg>cnt&&ed>cnt)
{
bg-=cnt;
ed-=cnt;
}
}
printf("%lld",ans);
return 0;
}
/*
3
-1 -1
0 0
1 1
3
1 2
2 3
3 4
3
-1 0
0 0
1 0
3
0 -1
0 0
0 1
3
-1 1
0 0
1 -1
5
0 0
30 0
-20 0
0 -1
0 100
3
-1 -1
1 -1
0 1
*/