#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Point; // 定义点的类型,使用long long存储坐标
// 计算向量OA和OB的叉积,用于判断点的相对位置
ll cross(const Point &O, const Point &A, const Point &B) {
return (A.first - O.first) * (B.second - O.second) - (A.second - O.second) * (B.first - O.first);
}
// 计算两点之间距离的平方,避免开方运算,提高效率
ll distSq(const Point &A, const Point &B) {
ll dx = A.first - B.first;
ll dy = A.second - B.second;
return dxdx + dydy;
}
// Andrew的单调链算法构建凸包
vector<Point> convexHull(vector<Point> &points) {
int n = points.size();
if (n <= 1) return points; // 如果点集少于等于1个点,直接返回
sort(points.begin(), points.end()); // 按照x坐标排序,若x相同则按y排序
vector<Point> hull; // 存储凸包的点
hull.reserve(n + 1); // 预分配空间,提高效率
}
// 旋转卡壳算法找到凸包的最大直径平方
ll rotatingCalipers(vector<Point> &hull) {
int n = hull.size();
if (n == 1) return 0; // 如果凸包只有一个点,直径为0
if (n == 2) return distSq(hull[0], hull[1]); // 如果凸包只有两个点,直接计算距离平方
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n; // 输入点的数量
vector<Point> points(n);
for (int i = 0; i < n; ++i) {
cin >> points[i].first >> points[i].second; // 输入每个点的坐标
}
vector<Point> hull = convexHull(points); // 构建凸包
cout << rotatingCalipers(hull) << endl; // 计算并输出凸包直径的平方
return 0;
}