Photo of The Sky

Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes.

Strictly speaking, it makes a photo of all points with coordinates (x,y)(x,y), such that x1≤x≤x2x1≤x≤x2 and y1≤y≤y2y1≤y≤y2, where (x1,y1)(x1,y1) and (x2,y2)(x2,y2) are coordinates of the left bottom and the right top corners of the rectangle being photographed. The area of this rectangle can be zero.

After taking the photo, Pavel wrote down coordinates of nn of his favourite stars which appeared in the photo. These points are not necessarily distinct, there can be multiple stars in the same point of the sky.

Pavel has lost his camera recently and wants to buy a similar one. Specifically, he wants to know the dimensions of the photo he took earlier. Unfortunately, the photo is also lost. His notes are also of not much help; numbers are written in random order all over his notepad, so it’s impossible to tell which numbers specify coordinates of which points.

Pavel asked you to help him to determine what are the possible dimensions of the photo according to his notes. As there are multiple possible answers, find the dimensions with the minimal possible area of the rectangle.

Input

The first line of the input contains an only integer nn (1≤n≤1000001≤n≤100000), the number of points in Pavel’s records.

The second line contains 2⋅n2⋅n integers a1a1, a2a2, …, a2⋅na2⋅n (1≤ai≤1091≤ai≤109), coordinates, written by Pavel in some order.

Output

Print the only integer, the minimal area of the rectangle which could have contained all points from Pavel’s records.

Examples

input

Copy

4
4 1 3 2 3 2 1 3
output

Copy

1
input

Copy

3
5 8 5 5 7 5
output

Copy

0
Note

In the first sample stars in Pavel’s records can be (1,3)(1,3), (1,3)(1,3), (2,3)(2,3), (2,4)(2,4). In this case, the minimal area of the rectangle, which contains all these points is 11 (rectangle with corners at (1,3)(1,3) and (2,4)(2,4)).

有两种情况,a1和an在或不在同一水平面上,不在的话就是左下和右上了,在的话要枚举一遍看看那两个相隔最近作为上界和下界。

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[200005];
int main()
{
    int n;
    scanf("%d",&n);
    n*=2;
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    sort(a+1,a+1+n);
    ll ans=(a[n/2]-a[1])*(a[n]-a[n/2+1]);
    for(int i=1;i<n/2;i++)
        ans=min(ans,(a[n]-a[1])*(a[n/2+i]-a[i+1]));
    printf("%lld\n",ans);
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值