#include <iostream> //求平面最远点对,由于最远点对必然在凸包上,所以先构建出凸包,再枚举凸包上的点
#include <algorithm>
using namespace std;
struct point
{
int x,y;
}st;
point dot[50001];
int dis(point a,point b) //这道题的两点距离并不用开平方
{
return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y); //耗时为200ms左右,但若使用 pow函数时间会暴增到2500ms左右
}
int cmp(const point& a,const point& b)
{
if((b.x-st.x)*(a.y-st.y)==(a.x-st.x)*(b.y-st.y))
return dis(st,a)<dis(st,b);
else
return (b.x-st.x)*(a.y-st.y)<(a.x-st.x)*(b.y-st.y);
}
bool left(point a,point b,point c)
//a,b,c分别为 dot[s[t-1]],dot[s[t]],dot[i],
//如果直线ac的斜率大于ab的斜率,则说明从ab到ac做左转,即ac在ab的逆时针方向,c点才可以加入堆栈中
{
return (c.y-a.y)*(b.x-a.x) >= (b.y-a.y)*(c.x-a.x); //(c.y-a.y)/(c.x-a.x) > (b.y-a.y)/(b.x-a.x)
//要特别注意=的情况,相等说明c在直线ab上,判断左转时这种同直线的情况也要考虑,若只是 > ,则 RE
}
int main()
{
int n,idx=0;
scanf("%d",&n);
for(int i=0;i<n;++i)
{
scanf("%d%d",&dot[i].x,&dot[i].y);
if(dot[i].y<dot[idx].y||(dot[i].y==dot[idx].y&&dot[i].x<dot[idx].x))
idx=i;
}
st.x=dot[idx].x;st.y=dot[idx].y;
if(n==2)
{
printf("%d\n",dis(dot[0],dot[1]));
return 0;
}
sort(dot,dot+n,cmp);
int t=-1;
int s[50001];
s[++t]=0;s[++t]=1;s[++t]=2;
for(int i=3;i<n;++i)
{
while(!left(dot[s[t-1]],dot[s[t]],dot[i]))
--t;
s[++t]=i;
}
int res=0;
for(int i=0;i<t;++i)
for(int j=i+1;j<=t;++j)
{
int tmp=dis(dot[s[i]],dot[s[j]]); //枚举凸包每两点的距离
res=res>tmp?res:tmp;
}
printf("%d\n",res);
return 0;
}