#include <bits/stdc++.h>

using namespace std;

#define SZ(x) ((int)(x).size())
#define PB(x) push_back(x)
#define MEMSET(x,v) memset(x,v,sizeof(x))
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define x first
#define y second

template<class A, class B> inline bool mina(A &x, B y) {return (x > y)?(x=y,1):0;}
template<class A, class B> inline bool maxa(A &x, B y) {return (x < y)?(x=y,1):0;}

typedef pair<int, int> P2;
typedef long long LL;

#define INF (0x3f3f3f3f)

#define MAXN (1000005)

int N, K;
int V[MAXN];
int C[MAXN];
int next_greater[MAXN];
P2 potential[MAXN];
int final_potential[MAXN];
int rc_minn[MAXN];

int main() {
    scanf("%d %d", &N, &K);
    REP(i, N) scanf("%d", &V[i]);
    REP(i, N) scanf("%d", &C[i]);
    next_greater[N - 1] = N;
    rc_minn[N - 1] = C[N - 1];
    for (int i = N - 2; i >= 0; i--) {
        int now = i + 1;
        int mm = C[i];
        while (now < N && V[now] <= V[i]) {
            mina(mm, rc_minn[next_greater[now]]);
            now = next_greater[now];
        }
        next_greater[i] = now;
        rc_minn[i] = mm;
    }
    potential[N - 1] = P2(V[N - 1], C[N - 1]);
    for (int i = N - 2; i >= 0; i--) {
        if (next_greater[i] == N) {
            potential[i] = P2(V[i], C[i]);
        } else {
            int ng = next_greater[i];
            int pp = min(rc_minn[i], potential[ng].y);
            if (min(100 * potential[ng].x, pp) >
                min(100 * V[i], C[i])) {
                potential[i] = P2(potential[ng].x, pp);
            } else {
                potential[i] = P2(V[i], C[i]);
            }
        }
    }
    REP(i, N) {
        final_potential[i] = min(100 * potential[i].x, potential[i].y);
//        cout << final_potential[i] << ": " << potential[i].x << "|" << potential[i].y << endl;
    }
    sort(final_potential, final_potential + N);
    double ans = 0.0;
    double p1 = 1.0 * K / N;
    int a = N - K;
    int b = N - 1;
    for (int i = 0; N - i - 1 >= K - 1; i++) {
//        cout << final_potential[i] << endl;
        ans += final_potential[i] * p1;
        p1 *= a;
        p1 /= b;
        a--;
        b--;
    }
    printf("%.9lf\n", ans);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define SZ(x) ((int)(x).size())
#define PB(x) push_back(x)
#define MEMSET(x,v) memset(x,v,sizeof(x))
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define x first
#define y second

template<class A, class B> inline bool mina(A &x, B y) {return (x > y)?(x=y,1):0;}
template<class A, class B> inline bool maxa(A &x, B y) {return (x < y)?(x=y,1):0;}

typedef pair<int, int> P2;
typedef long long LL;

#define INF (0x3f3f3f3f)

#define MAXN (10000005)

template<class T>
class RangeMinimumQuery {
public:
    vector<vector<int> > M;
    vector<T> A;
    int N;
    RangeMinimumQuery(T in[], int n) {
        N = n;
        M = vector<vector<int> >(N + 5);
        A = vector<T> (N + 5);
        for (int i = 0; i < N + 5; i++)
            M[i] = vector<int> (25);

        //initialize M for the intervals with length 1
        for (int i = 0; i < N; i++) {
            M[i][0] = i;
            A[i] = in[i];
        }
        //compute values from smaller to bigger intervals
        for (int j = 1; 1<<j <= N; j++){
            for (int i = 0; i + (1<<j) - 1 < N; i++)
                if (A[M[i][j - 1]] < A[M[i + (1 << (j - 1))][j - 1]]) M[i][j] = M[i][j - 1];
                else M[i][j] = M[i + (1 << (j - 1))][j - 1];
        }
    }

    // returns min(A[left...right])
    // also can be modified to return the index
    T get_min(int left, int right) {
        int num = right - left + 1;
        int e = 1, k = 0;
        while (e * 2 <= num) e *= 2, k++;
        int temp = right - e + 1;
        if (A[M[left][k]] <= A[M[temp][k]]) return A[M[left][k]];
        else return A[M[temp][k]];
    }
};

int N, K;
int V[MAXN];
int C[MAXN];
int next_greater[MAXN];
P2 potential[MAXN];
int final_potential[MAXN];
int main() {
   scanf("%d %d", &N, &K);
    REP(i, N) scanf("%d", &V[i]);
    REP(i, N) scanf("%d", &C[i]);
    RangeMinimumQuery<int> rc(C, N);
    next_greater[N - 1] = N;
    for (int i = N - 2; i >= 0; i--) {
        int now = i + 1;
        while (now < N && V[now] <= V[i]) {
            now = next_greater[now];
        }
        next_greater[i] = now;
    }
    potential[N - 1] = P2(V[N - 1], C[N - 1]);
    for (int i = N - 2; i >= 0; i--) {
        if (next_greater[i] == N) {
            potential[i] = P2(V[i], C[i]);
        } else {
            int ng = next_greater[i];
            int pp = min(rc.get_min(i, ng), potential[ng].y);
            if (min(100 * potential[ng].x, pp) >
                min(100 * V[i], C[i])) {
                potential[i] = P2(potential[ng].x, pp);
            } else {
                potential[i] = P2(V[i], C[i]);
            }
        }
    }
    REP(i, N) {
        final_potential[i] = min(100 * potential[i].x, potential[i].y);
//        cout << final_potential[i] << ": " << potential[i].x << "|" << potential[i].y << endl;
    }
    sort(final_potential, final_potential + N);
    double ans = 0.0;
    double p1 = 1.0 * K / N;
    int a = N - K;
    int b = N - 1;
    for (int i = 0; N - i - 1 >= K - 1; i++) {
//        cout << final_potential[i] << endl;
        ans += final_potential[i] * p1;
        p1 *= a;
        p1 /= b;
        a--;
        b--;
    }
    printf("%.9lf\n", ans);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define SZ(x) ((int)(x).size())
#define PB(x) push_back(x)
#define MEMSET(x,v) memset(x,v,sizeof(x))
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define x first
#define y second
#define INF (0x3f3f3f3f)
#ifndef PING128
    #define cerr if(false) cout
#endif
typedef long long LL;
typedef pair<int, int> P2;
template<class A, class B> inline bool mina(A &x, B y) {return (x > y)?(x=y,1):0;}
template<class A, class B> inline bool maxa(A &x, B y) {return (x < y)?(x=y,1):0;}

const int MAXN = 1e6+5;

template<class T>
class RangeMinimumQuery {
public:
    vector<vector<int> > M;
    vector<T> A;
    int N;
    RangeMinimumQuery(T in[], int n) {
        N = n;
        M = vector<vector<int> >(N + 5);
        A = vector<T> (N + 5);
//        int b; for (b = 0; 1<<b <= N; b++);
        for (int i = 0; i < N + 5; i++)
            M[i] = vector<int> (25);
        //initialize M for the intervals with length 1
        for (int i = 0; i < N; i++) {
            M[i][0] = i;
            A[i] = in[i];
        }
        //compute values from smaller to bigger intervals
        for (int j = 1; 1<<j <= N; j++){
            for (int i = 0; i + (1<<j) - 1 < N; i++)
                if (A[M[i][j - 1]] < A[M[i + (1 << (j - 1))][j - 1]]) M[i][j] = M[i][j - 1];
                else M[i][j] = M[i + (1 << (j - 1))][j - 1];
        }
    }

    // returns min(A[left...right])
    // also can be modified to return the index
    T get_min(int left, int right) {
        int num = right - left + 1;
        int e = 1, k = 0;
        while (e * 2 <= num) e *= 2, k++;
        int temp = right - e + 1;
        if (A[M[left][k]] <= A[M[temp][k]]) return A[M[left][k]];
        else return A[M[temp][k]];
    }
};

int N, K;
int V[MAXN];
int C[MAXN];
int next_greater[MAXN];
P2 potential[MAXN];
int final_potential[MAXN];
int main() {
   scanf("%d %d", &N, &K);
    REP(i, N) scanf("%d", &V[i]);
    REP(i, N) scanf("%d", &C[i]);
    RangeMinimumQuery<int> rc(C, N);
    next_greater[N - 1] = N;
    for (int i = N - 2; i >= 0; i--) {
        int now = i + 1;
        while (now < N && V[now] <= V[i]) {
            now = next_greater[now];
        }
        next_greater[i] = now;
    }
    potential[N - 1] = P2(V[N - 1], C[N - 1]);
    for (int i = N - 2; i >= 0; i--) {
        if (next_greater[i] == N) {
            potential[i] = P2(V[i], C[i]);
        } else {
            int ng = next_greater[i];
            int pp = min(rc.get_min(i, ng), potential[ng].y);
            if (min(100 * potential[ng].x, pp) >
                min(100 * V[i], C[i])) {
                potential[i] = P2(potential[ng].x, pp);
            } else {
                potential[i] = P2(V[i], C[i]);
            }
        }
    }
    REP(i, N) {
        final_potential[i] = min(100 * potential[i].x, potential[i].y);
        cerr << final_potential[i] << ": " << potential[i].x << "|" << potential[i].y << endl;
    }
    sort(final_potential, final_potential + N);
    double ans = 0.0;
    double p1 = 1.0 * K / N;
    int a = N - K;
    int b = N - 1;
    for (int i = 0; N - i - 1 >= K - 1; i++) {
        cerr << final_potential[i] << endl;
        ans += final_potential[i] * p1;
        p1 *= a;
        p1 /= b;
        a--;
        b--;
    }
    printf("%.9lf\n", ans);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define SZ(x) ((int)(x).size())
#define PB(x) push_back(x)
#define MEMSET(x,v) memset(x,v,sizeof(x))
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define x first
#define y second

template<class A, class B> inline bool mina(A &x, B y) {return (x > y)?(x=y,1):0;}
template<class A, class B> inline bool maxa(A &x, B y) {return (x < y)?(x=y,1):0;}

typedef pair<int, int> P2;
typedef long long LL;

#define INF (0x3f3f3f3f)

#define MAXN (10000005)

int N, K;
int V[MAXN];
int C[MAXN];
int next_greater[MAXN];
P2 potential[MAXN];
int final_potential[MAXN];
int rc_minn[MAXN];

int main() {
   scanf("%d %d", &N, &K);
    REP(i, N) scanf("%d", &V[i]);
    REP(i, N) scanf("%d", &C[i]);
    next_greater[N - 1] = N;
    rc_minn[N - 1] = C[N - 1];
    for (int i = N - 2; i >= 0; i--) {
        int now = i + 1;
        int mm = C[i];
        while (now < N && V[now] <= V[i]) {
            mina(mm, rc_minn[next_greater[now]]);
            now = next_greater[now];
        }
        next_greater[i] = now;
        rc_minn[i] = mm;
    }
    potential[N - 1] = P2(V[N - 1], C[N - 1]);
    for (int i = N - 2; i >= 0; i--) {
        if (next_greater[i] == N) {
            potential[i] = P2(V[i], C[i]);
        } else {
            int ng = next_greater[i];
            int pp = min(rc_minn[i], potential[ng].y);
            if (min(100 * potential[ng].x, pp) >
                min(100 * V[i], C[i])) {
                potential[i] = P2(potential[ng].x, pp);
            } else {
                potential[i] = P2(V[i], C[i]);
            }
        }
    }
    REP(i, N) {
        final_potential[i] = min(100 * potential[i].x, potential[i].y);
//        cout << final_potential[i] << ": " << potential[i].x << "|" << potential[i].y << endl;
    }
    sort(final_potential, final_potential + N);
    double ans = 0.0;
    double p1 = 1.0 * K / N;
    int a = N - K;
    int b = N - 1;
    for (int i = 0; N - i - 1 >= K - 1; i++) {
//        cout << final_potential[i] << endl;
        ans += final_potential[i] * p1;
        p1 *= a;
        p1 /= b;
        a--;
        b--;
    }
    printf("%.9lf\n", ans);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define SZ(x) ((int)(x).size())
#define PB(x) push_back(x)
#define MEMSET(x,v) memset(x,v,sizeof(x))
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define x first
#define y second
#define INF (0x3f3f3f3f)
#ifndef PING128
    #define cerr if(false) cout
#endif
typedef long long LL;
typedef pair<int, int> P2;
template<class A, class B> inline bool mina(A &x, B y) {return (x > y)?(x=y,1):0;}
template<class A, class B> inline bool maxa(A &x, B y) {return (x < y)?(x=y,1):0;}

const int MAXN = 1e6+5;

template<class T>
class RangeMinimumQuery {
public:
    vector<vector<int> > M;
    vector<T> A;
    int N;
    RangeMinimumQuery(T in[], int n) {
        N = n;
        M = vector<vector<int> >(N + 5);
        A = vector<T> (N + 5);
        int b; for (b = 0; 1<<b <= N; b++);
        for (int i = 0; i < N + 5; i++)
            M[i] = vector<int> (b);
        //initialize M for the intervals with length 1
        for (int i = 0; i < N; i++) {
            M[i][0] = i;
            A[i] = in[i];
        }
        //compute values from smaller to bigger intervals
        for (int j = 1; 1<<j <= N; j++){
            for (int i = 0; i + (1<<j) - 1 < N; i++)
                if (A[M[i][j - 1]] < A[M[i + (1 << (j - 1))][j - 1]]) M[i][j] = M[i][j - 1];
                else M[i][j] = M[i + (1 << (j - 1))][j - 1];
        }
    }

    // returns min(A[left...right])
    // also can be modified to return the index
    T get_min(int left, int right) {
        int num = right - left + 1;
        int e = 1, k = 0;
        while (e * 2 <= num) e *= 2, k++;
        int temp = right - e + 1;
        if (A[M[left][k]] <= A[M[temp][k]]) return A[M[left][k]];
        else return A[M[temp][k]];
    }
};

int N, K;
int V[MAXN];
int C[MAXN];
int next_greater[MAXN];
P2 potential[MAXN];
int final_potential[MAXN];
int main() {
   scanf("%d %d", &N, &K);
    REP(i, N) scanf("%d", &V[i]);
    REP(i, N) scanf("%d", &C[i]);
    RangeMinimumQuery<int> rc(C, N);
    next_greater[N - 1] = N;
    for (int i = N - 2; i >= 0; i--) {
        int now = i + 1;
        while (now < N && V[now] <= V[i]) {
            now = next_greater[now];
        }
        next_greater[i] = now;
    }
    potential[N - 1] = P2(V[N - 1], C[N - 1]);
    for (int i = N - 2; i >= 0; i--) {
        if (next_greater[i] == N) {
            potential[i] = P2(V[i], C[i]);
        } else {
            int ng = next_greater[i];
            int pp = min(rc.get_min(i, ng), potential[ng].y);
            if (min(100 * potential[ng].x, pp) >
                min(100 * V[i], C[i])) {
                potential[i] = P2(potential[ng].x, pp);
            } else {
                potential[i] = P2(V[i], C[i]);
            }
        }
    }
    REP(i, N) {
        final_potential[i] = min(100 * potential[i].x, potential[i].y);
        cerr << final_potential[i] << ": " << potential[i].x << "|" << potential[i].y << endl;
    }
    sort(final_potential, final_potential + N);
    double ans = 0.0;
    double p1 = 1.0 * K / N;
    int a = N - K;
    int b = N - 1;
    for (int i = 0; N - i - 1 >= K - 1; i++) {
        cerr << final_potential[i] << endl;
        ans += final_potential[i] * p1;
        p1 *= a;
        p1 /= b;
        a--;
        b--;
    }
    printf("%.9lf\n", ans);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,ans=0;
int a[100001];
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++){scanf ("%d",&a[i]);if(a[i]==a[i-1])ans++;}
if(ans==n){puts("NO"); return 0;}
else sort(a+1,a+n+1);
unique(a+1,a+n+1);
printf("%d\n",a[2]);
return 0;
}


#include <iostream>
#pragma GCC optimize(2)
using namespace std;
int n,a,b=0;
bool p[201];
int main()
{
	cin>>n;
	while(n--)
	{
		cin>>a;
		p[a+100]++;
	}
	for(int i=0; i<=200; i++)
	{
		if(p[i])  b++;
		if(b==2)
		{
			cout<<i-100<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[10086];
int main()
{
	int n,b;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	b=unique(a,a+n+1)-a;
	if(b>=2)
	{
		for(int i=1;i<=b;i++)
		{
		cout<<a[2];
		break;
		}
	}
	else printf("NO");
	return 0;
}


#include<iostream>
using namespace std;
int a[100001],n,ans,maxn;
int main()
{
	cin>>n;
	for(int i=1,x;i<=n;i++)
	{
		cin>>x;
		a[x+100]++;
		maxn=max(maxn,x+100);
	}
	for(int i=0;i<=maxn;i++)
	{
		if(a[i])
			ans++;
		if(ans==2)
		{
			cout<<i-100<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
}


#include <iostream>
using namespace std;
int a[110],sum,n;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
		if(n==1) { cout<<"NO"; return 0; }
	for(int i=0;i<n-1;i++)
		for(int j=i+1;j<n;j++)
			if(a[i]>a[j]) swap(a[i],a[j]);
	for(int i=0;i<n;i++)
	{
		sum++;
		if(sum>=2&&a[i]!=a[i-1]) { cout<<a[i]; return 0; }
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include<algorithm>
#include <iostream>
using namespace std;
int main () {
	int n,arr[200],k=0;
	scanf("%d",&n);
	for(int i=0; i<n; i++) {
		scanf("%d",&arr[i]);
	}
	sort(arr,arr+n);
	for(int i=0; i<n; i++) {
		if(arr[i]!=arr[i+1]) k++;
		if(k==2) {
			printf("%d",arr[i]);
			return 0;
		}
	}
	if(k!=2) printf("NO");
	return 0;

}


#include<set>
#include<cstdio>
using namespace std;

int n;
set<int> s;
set<int>::iterator it;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		s.insert(x);
	}
	it=s.begin();
	for(int cnt=1;;it++,cnt++){
		if(cnt==2){
			printf("%d",*it);
			return 0;
		}
	}
}


#include<bits/stdc++.h>
#include<iomanip>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<math.h>
#include<vector>
#include<stack>
#include<time.h>
#include<queue>
#include<set>
#include<map>
#include<cstdlib>
#include<cstring>
#include<stdio.h>
#include<cmath>
#include<string>
#include<fstream>
#include<string.h>
using namespace std;
int a[101],f[201],n,s,q;
int main()
{
	int i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
    	cin>>q;
		if(f[q+100]!=0)
		continue;
    	f[q+100]++;
    	a[i]=q;
    }
    sort(a+1,a+n+1);
    if(a[2]==0)
    cout<<"NO";
    else
    cout<<a[2];
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int a[110];
int main()
{
	int n;
	cin>>n;
	bool flag=true;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(i!=1&&a[i]!=a[i-1])
			flag=false;
	}
	if(n==1)
	{
		cout<<"NO";
		return 0;
	}
	if(flag)
	{
		cout<<"NO";
		return 0;
	}
	sort(a+1,a+1+n);
	for(int i=2;i<=n;i++)
	{
		if(a[i]!=a[i-1])
		{
			cout<<a[i];
			return 0;
		}
	}
}


#include<iostream>
#include<algorithm>

using namespace std;
int main()
{
int n,a[200001];
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i];
sort(a+1,a+n+1);
for(int i=2;i<=n;i++)
{
	if(a[i]!=a[1])
	{
		cout<<a[i];
		break;
	}
	else continue;
}
if(a[1]==a[n]) cout<<"NO";
return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[100001];
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    if(n==1)
    {
        cout<<"NO";
        return 0;
    }
    else
    {
        for(int i=1; i<=n; i++)
        {
            if(i==n)
            {
                if(a[i]!=a[i-1])
                {
                    cout<<a[i]<<endl;
                    return 0;
                }
                else
                {
                    break;
                }
            }
            if(a[i]!=a[i+1]&&i<n)
            {
                cout<<a[i+1]<<endl;
                return 0;
            }
        }
    }
    return 0;
}


#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	long long a,n[101],ij=1,j;
	cin>>a;
	for(int i=0;i<a;i++)
	{
		cin>>n[i];
	}
	sort(n,n+a);
	j=n[0];
	for(int i=0;i<a;i++)
	{
		if(j!=n[i])
		{
			j=n[i];
			ij++;
		}
		if(ij==2)
		{
			cout<<n[i];
			return 0;
		}
	}
	cout<<"NO"<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define maxn 107
int n,a[maxn],l;

inline void Init()
{
	scanf("%d",&n);
	for(register int i=1;i<=n;i++) scanf("%d",&a[i]);
}
inline void Work()
{
	sort(a+1,a+n+1);
	l=a[1];
	for(register int i=1;i<=n;i++)
	{
		if(a[i]!=l){
			printf("%d\n",a[i]);
			return;
		}
	}
	printf("NO\n");
}
int main()
{
	Init();
	Work();
	return 0;
}
//fff


#include<iostream>
#include<cstdio>
using namespace std;
int n,a,cnr=0,p[201];
int main()
{
    ios::sync_with_stdio(0);
    cin>>n;
    while(n--)
    {
        cin>>a;
        p[a+100]++;
    }
    for(int i=0;i<=200;i++)
    {
        if(p[i]) cnr++;
        if(cnr==2)
        {
            cout<<i-100<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,x,a,b;
	cin>>n;
    for(int i=0;i<n;i++)
	{
        cin>>x;
        if(x==a||x==b)
		{
            continue;
        }
        if(x<a)
		{
            b=a;
            a=x;
        }
		else if(x<b)
		{
            b=x;
        }
    }
    if(b==101||b<2)
	{
        cout<<"NO";
    }
	else
	{
        cout<<b+1;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[100001];
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    if(n==1)
    {
        cout<<"NO";
        return 0;
    }
    else
    {
        for(int i=1; i<=n; i++)
        {
            if(i==n)
            {
                if(a[i]!=a[i-1])
                {
                    cout<<a[i]<<endl;
                    return 0;
                }
                else
                {
                    break;
                }
            }
            if(a[i]!=a[i+1]&&i<n)
            {
                cout<<a[i+1]<<endl;
                return 0;
            }
        }
    }
    cout<<"NO";
    return 0;
}


#include<cstdio>
using namespace std;
int i,n,a[10000],min,smin=-1000000;
int main()
{
    scanf("%d\n",&n);
    scanf("%d",&min);
    for(i=1;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]<min)smin=min,min=a[i];
           else if(a[i]>min&&a[i]<smin)smin=a[i];
    }
    if(smin!=-1000000)printf("%d",smin);
       else printf("NO");
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int n,k,a[10002],s[10002],z;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++)
        if(a[i]!=a[i+1])s[++z]=a[i];
    if(z<2){cout<<"NO RESULT";
    return 0;
    }
    sort(s+1,s+z+1);
    cout<<s[2];
    return 0;
}


#include"iostream"
#include"cstdio"
#include"cstdlib"
#include"string"
#include"cmath"
#include"algorithm"
using namespace std;
int n,x,ans=101,minn=101;
int main(){
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>x;
        if(x==minn||x==ans){
            continue;
        }
        if(x<minn){
            ans=minn;
            minn=x;
        }else if(x<ans){
            ans=x;
        }
    }
    if(ans==101){
        cout<<"NO";
    }else{
        cout<<ans;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[128];
int main()
{
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(i=1;i<n;i++)
		if(a[i]!=a[i+1])
		{
			printf("%d",a[i+1]);
			return 0;
		}
	printf("NO");
	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,a[101]={0},ok=1,cnt=1;
    cin>>n;
    for(int i=0;i<n;++i) cin>>a[i];
    sort(a,a+n);
    for(int i=1;i<n;++i)
    {
        if(a[i]!=a[i-1]) cnt++;
        if(cnt==2) { cout<<a[i]; ok=0; break; }
    }
    if(ok) cout<<"NO";
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<algorithm>
using namespace std;
const int N=100000;
int n,a[N],s=1;
map<int,int> b;
main()
{
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        scanf("%d",&a[i]);
        b[a[i]]++;
    }
    for(int i=-100;i<=100;++i)
    {
        if(b[i]!=0)
        {
            if(s==0)
            {
                cout<<i;return 0;
            }
            else s--;
        }
    }
    cout<<"NO";
}


#include<bits/stdc++.h>
using namespace std;
int l,n,k;
int a[1000];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]!=a[i-1]&&i!=1)
		k=1;
	}
	if(k==0)	printf("NO");
	else{
		sort(a+1,a+1+n);
		l=2;
		while(a[l]==a[l-1])	l++;
		printf("%d",a[l]);
	}
}


#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[105]={0};
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)
	{
		if(a[i]<a[i+1])
		{
			cout<<a[i+1]<<endl;
			break;
		}
	}
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
int n,a[1000],i;
cin>>n;
for(i=0;i<n;i++)
{
    cin>>a[i];
}
int min2=90000;
int min=a[0];
for(i=0;i<n;i++)
{
   if(a[i]<min)
   {
      min=a[i];
   }
}
for(i=0;i<n;i++)
{
  if(a[i]<min2 && a[i]!=min)
  {
     min2=a[i];
  }
}
if(min2==min || n==1)
{
    cout<<"NO"<<endl;
}
else
{
    cout<<min2<<endl;
}
return 0;
}


#include<iostream>
using namespace std;
int main()
{
int n,a[1000],i;
cin>>n;
for(i=0;i<n;i++)
{
    cin>>a[i];
}
int min2=90000;
int min=a[0];
bool flag=true;
for(i=1;i<n;i++)
{
    if(a[i-1]!=a[i])
       flag=false;
}
for(i=0;i<n;i++)
{
   if(a[i]<min)
   {
      min=a[i];
   }
}
for(i=0;i<n;i++)
{
  if(a[i]<min2 && a[i]!=min)
  {
     min2=a[i];
  }
}
if(n==1 || flag)
{
    cout<<"NO"<<endl;
}
else
{
    cout<<min2<<endl;
}
return 0;
}


#include<iostream>
using namespace std;
int main()
{
long long n,a[1000],i;
cin>>n;
for(i=0;i<n;i++)
{
    cin>>a[i];
}
long long min2=90000000000000000000;
long long min=a[0];
for(i=0;i<n;i++)
{
   if(a[i]<min)
   {
      min=a[i];
   }
}
for(i=0;i<n;i++)
{
  if(a[i]<min2 && a[i]!=min)
  {
     min2=a[i];
  }
}
cout<<min2<<endl;
return 0;
}


#include<iostream>
using namespace std;
int main()
{
int n,a[1000],i;
cin>>n;
for(i=0;i<n;i++)
{
    cin>>a[i];
}
int min2=90000;
int min=a[0];
for(i=0;i<n;i++)
{
   if(a[i]<min)
   {
      min=a[i];
   }
}
for(i=0;i<n;i++)
{
  if(a[i]<min2 && a[i]!=min)
  {
     min2=a[i];
  }
}
if(min2==min)
{
    cout<<"NO"<<endl;
}
else
{
    cout<<min2<<endl;
}
return 0;
}


#include<iostream>
using namespace std;
int main()
{
int n,a[1000],i;
cin>>n;
for(i=0;i<n;i++)
{
    cin>>a[i];
}
long long min2=9000000000000000000000;
int min=a[0];
for(i=0;i<n;i++)
{
   if(a[i]<min)
   {
      min=a[i];
   }
}
for(i=0;i<n;i++)
{
  if(a[i]<min2 && a[i]!=min)
  {
     min2=a[i];
  }
}
cout<<min2<<endl;
return 0;
}


#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef std::vector <ll> vll;
typedef std::pair <ll, ll> ii;
typedef std::pair <ll, ii> iii;

const ll maxn = 1e3+5;
const ll maxint = 1e9+7;
const ll base = 1e9;

int64_t k,x;
int64_t dem=0;
int a[1000001];
std::string s;
void Fix (vll &a)
{
    a.push_back(0);
    for (ll i=0; i<a.size()-1; i++)
    {
        a[i+1] += a[i]/base;
        a[i] %= base;
        if (a[i]<0)
        {
            a[i+1]--;
            a[i] += base;
        }
    }
    while (!a.back() && a.size()>1) a.pop_back();
}
bool operator < (const vll &a, const vll &b)
{
    if (a.size()!=b.size()) return (a.size()<b.size());
    for (ll i=a.size()-1; i>=0; i--)
        if (a[i]!=b[i]) return (a[i]<b[i]);
    return false;
}

void Scan (vll &a)
{
    std::string s;
    std::cin >> s;
    a.clear();
    a.resize(s.size()/9+1);
    for (ll i=0; i<s.size(); i++)
    {
        ll x = (s.size()-1-i)/9;
        a[x] = a[x]*10 + (s[i]-'0');
    }
    Fix(a);
}
void sang(long n)
{
    int i,j,u;
    long x=(long)sqrt(n);
    for(i=1;; i++)
    {
        k=i*2+1;
        if(k>x) break;
        u=(n+1)/k;
    }
}


#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef std::vector <ll> vll;
typedef std::pair <ll, ll> ii;
typedef std::pair <ll, ii> iii;

const ll maxn = 1e3+5;
const ll maxint = 1e9+7;
const ll base = 1e9;

int64_t k,x;
int64_t dem=0;
int a[1000001];
std::string s;
void Fix (vll &a)
{
    a.push_back(0);
    for (ll i=0; i<a.size()-1; i++)
    {
        a[i+1] += a[i]/base;
        a[i] %= base;
        if (a[i]<0)
        {
            a[i+1]--;
            a[i] += base;
        }
    }
    while (!a.back() && a.size()>1) a.pop_back();
}
void Scan (vll &a)
{
    std::string s;
    std::cin >> s;
    a.clear();
    a.resize(s.size()/9+1);
    for (ll i=0; i<s.size(); i++)
    {
        ll x = (s.size()-1-i)/9;
        a[x] = a[x]*10 + (s[i]-'0');
    }
    Fix(a);
}
void sang(long n)
{
    int i,j,u;
    long x=(long)sqrt(n);
    for(i=1;; i++)
    {
        k=i*2+1;
        if(k>x) break;
        u=(n+1)/k;
    }
}


#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef std::vector <ll> vll;
typedef std::pair <ll, ll> ii;
typedef std::pair <ll, ii> iii;

const ll maxn = 1e3+5;
const ll maxint = 1e9+7;
const ll base = 1e9;

int64_t k,x;
int64_t dem=0;
int a[1000001];
std::string s;
void Fix (vll &a)
{
    a.push_back(0);
    for (ll i=0; i<a.size()-1; i++)
    {
        a[i+1] += a[i]/base;
        a[i] %= base;
        if (a[i]<0)
        {
            a[i+1]--;
            a[i] += base;
        }
    }
    while (!a.back() && a.size()>1) a.pop_back();
}
bool operator < (const vll &a, const vll &b)
{
    if (a.size()!=b.size()) return (a.size()<b.size());
    for (ll i=a.size()-1; i>=0; i--)
        if (a[i]!=b[i]) return (a[i]<b[i]);
    return false;
}

void Scan (vll &a)
{
    std::string s;
    std::cin >> s;
    a.clear();
    a.resize(s.size()/9+1);
    for (ll i=0; i<s.size(); i++)
    {
        ll x = (s.size()-1-i)/9;
        a[x] = a[x]*10 + (s[i]-'0');
    }
    Fix(a);
}
void sang(long n)
{
    int i,j,u;
    long x=(long)sqrt(n);
    for(i=1;; i++)
    {
        k=i*2+1;
        if(k>x) break;
        u=(n+1)/k;
    }
}
int main()
{
    int64_t n;
    std::cin>>n;
    int x[n];
    for(int i=1; i<=n; i++)
        std::cin>>x[i];
    std::sort(x+1,x+n+1);
    for(int i=1; i<=n; i++)
        if(x[i]!=x[1])
        {
            std::cout<<x[i]<<"\n";
            return 0;
        }
    std::cout<<"NO"<<"\n";
}


#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef std::vector <ll> vll;
typedef std::pair <ll, ll> ii;
typedef std::pair <ll, ii> iii;

int64_t k,x;
int64_t dem=0;
int a[1000001];
std::string s;
void Fix (vll &a)
{
    a.push_back(0);
    for (ll i=0; i<a.size()-1; i++)
    {
        a[i+1] += a[i]/base;
        a[i] %= base;
        if (a[i]<0)
        {
            a[i+1]--;
            a[i] += base;
        }
    }
    while (!a.back() && a.size()>1) a.pop_back();
}
bool operator < (const vll &a, const vll &b)
{
    if (a.size()!=b.size()) return (a.size()<b.size());
    for (ll i=a.size()-1; i>=0; i--)
        if (a[i]!=b[i]) return (a[i]<b[i]);
    return false;
}

void Scan (vll &a)
{
    std::string s;
    std::cin >> s;
    a.clear();
    a.resize(s.size()/9+1);
    for (ll i=0; i<s.size(); i++)
    {
        ll x = (s.size()-1-i)/9;
        a[x] = a[x]*10 + (s[i]-'0');
    }
    Fix(a);
}
void sang(long n)
{
    int i,j,u;
    long x=(long)sqrt(n);
    for(i=1;; i++)
    {
        k=i*2+1;
        if(k>x) break;
        u=(n+1)/k;
    }
}
int main()
{
    int64_t n;
    std::cin>>n;
    int x[n];
    for(int i=1; i<=n; i++)
        std::cin>>x[i];
    std::sort(x+1,x+n+1);
    for(int i=1; i<=n; i++)
        if(x[i]!=x[1])
        {
            std::cout<<x[i]<<"\n";
            return 0;
        }
    std::cout<<"NO"<<"\n";
}


#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>

int main()
{
    int64_t n;
    std::cin>>n;
    int x[n];
    for(int i=1; i<=n; i++)
        std::cin>>x[i];
    std::sort(x+1,x+n+1);
    for(int i=1; i<=n; i++)
        if(x[i]!=x[1])
        {
            std::cout<<x[i]<<"\n";
            return 0;
        }
    std::cout<<"NO"<<"\n";
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,i;
    cin>>n;
    int array[n];
    for(i=0;i<n;i++)
    {
        cin>>array[i];
    }
    sort(array,array+n);

    for(int i=0;i<n;i++){
        if(array[i]<array[i+1]){
            cout<<array[i+1]<<endl;
            return 0;
        }

    }
    cout<<"NO"<<endl;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,i;
    cin>>n;
    int x[n];
    for(i=0;i<n;i++)
    {
        cin>>x[i];
    }
    sort(x,x+n);

    for(int i=1;i<n;i++){
		if(x[i]>x[i-1]){
			cout<<x[i]<<endl;
			return 0;
		}

	}
	cout<<"NO"<<endl;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,i;
    cin>>n;
    int x[n];
    for(i=0;i<n;i++)
    {
        cin>>x[i];
    }
    sort(x,x+n);
////    for(i=0;i<n;i++)
////    {
////        cout<<x[i]<<"    ";
////    }
    for(int i=0;i<n;i++){
        if(x[i]<x[i+1]){
            cout<<x[i+1]<<endl;
            return 0;//program aikhan thakay terminate hobe
        }

    }
    cout<<"No"<<endl;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,i;
    cin>>n;
    int x[n];
    for(i=0;i<n;i++)
    {
        cin>>x[i];
    }
    sort(x,x+n);

    for(int i=1;i<n;i++){
        if(x[i]>x[i-1]){
            cout<<x[i+1]<<endl;
            return 0;
        }

    }
    cout<<"No"<<endl;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,i;
    cin>>n;
    int array[n];
    for(i=0;i<n;i++)
    {
        cin>>array[i];
    }
    sort(array,array+n);

    for(int i=1;i<n;i++){
        if(array[i]>array[i-1]){
            cout<<array[i+1]<<endl;
            return 0;
        }

    }
    cout<<"no"<<endl;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,i;
    cin>>n;
    int x[n];
    for(i=0;i<n;i++)
    {
        cin>>x[i];
    }
    sort(x,x+n);
////    for(i=0;i<n;i++)
////    {
////        cout<<x[i]<<"    ";
////    }
    for(int i=0;i<n;i++){
        if(x[i]<x[i+1]){
            cout<<x[i+1]<<endl;
            return 0;//program aikhan thakay terminate hobe
        }

    }
    cout<<"no"<<endl;
}


#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin>>n;
    int array[n];
    for(int i=0;i<n;i++){
        cin>>array[i];
    }
    sort(array,array+n);
    for(int i=1;i<n;i++){
        if(array[i]>array[i-1]){
            cout<<array[i]<<endl;
            return 0;
        }
    }

    cout<<"NO"<<endl;

}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,i;
    cin>>n;
    int array[n];
    for(i=0;i<n;i++)
    {
        cin>>array[i];
    }
    sort(array,array+n);

    for(int i=1;i<n;i++){
        if(array[i]>array[i-1]){
            cout<<array[i]<<endl;
            return 0;
        }

    }
    cout<<"no"<<endl;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,i;
    cin>>n;
    int x[n];
    for(i=0;i<n;i++)
    {
        cin>>x[i];
    }
    sort(x,x+n);

    for(int i=1;i<n;i++){
		if(x[i]>x[i-1]){
			cout<<x[i-1]<<endl;
			return 0;
		}

	}
	cout<<"NO"<<endl;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
    cin>>a[i];

if(n==1)
    cout<<"No";
else{
sort(a,a+n);
int count=0,k=0;

for(int j=0;j<n-1;j++)
{

 if(a[j]==a[j+1])
    {a[j]=101;
    count++;
    }}
//for(int i=0;i<n;i++)
//    cout<<a[i];
int ans[n-count];
    for(int i=0;i<n;i++)
 {
     if(a[i]!=101)
{ans[k]=a[i];
k++;}}
//cout<<endl<<"abc"<<endl;
//for(int j=0;j<k;j++)
   //cout<<ans[j];

    if(k==1)
    cout<<"NO";
    else
cout<<ans[1];
}
return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
    cin>>a[i];

if(n==1)
    cout<<"No";
else{
sort(a,a+n);
int count=0,k=0;

for(int j=0;j<n-1;j++)
{

 if(a[j]==a[j+1])
    {a[j]=101;
    count++;
    }}
//for(int i=0;i<n;i++)
//    cout<<a[i];
int ans[n-count];
    for(int i=0;i<n;i++)
 {
     if(a[i]!=101)
{ans[k]=a[i];
k++;}}
//cout<<endl<<"abc"<<endl;
//for(int j=0;j<k;j++)
   //cout<<ans[j];

    cout<<ans[1];
}
return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
    cin>>a[i];

sort(a,a+n);
int count=0,k=0;

for(int j=0;j<n-1;j++)
{

 if(a[j]==a[j+1])
    {a[j]=101;
    count++;
    }}
//for(int i=0;i<n;i++)
//    cout<<a[i];
int ans[n-count];
    for(int i=0;i<n;i++)
 {
     if(a[i]!=101)
{ans[k]=a[i];
k++;}}
//cout<<endl<<"abc"<<endl;
//for(int j=0;j<k;j++)
   //cout<<ans[j];
   cout<<ans[1];
return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
    cin>>a[i];

sort(a,a+n);
int count=0,k=0;

for(int j=0;j<n-1;j++)
{

 if(a[j]==a[j+1])
    {a[j]=101;
    count++;
    }}
//for(int i=0;i<n;i++)
//    cout<<a[i];
int ans[n-count];
    for(int i=0;i<n;i++)
 {
     if(a[i]!=101)
{ans[k]=a[i];
k++;}}
//cout<<endl<<"abc"<<endl;
//for(int j=0;j<k;j++)
   //cout<<ans[j];
  if(ans[1]==0)
    cout<<"No";
    else
  cout<<ans[1];
return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
    cin>>a[i];

if(n==1)
    cout<<"NO";
else{
sort(a,a+n);
int count=0,k=0;

for(int j=0;j<n-1;j++)
{

 if(a[j]==a[j+1])
    {a[j]=101;
    count++;
    }}
//for(int i=0;i<n;i++)
//    cout<<a[i];
int ans[n-count];
    for(int i=0;i<n;i++)
 {
     if(a[i]!=101)
{ans[k]=a[i];
k++;}}
//cout<<endl<<"abc"<<endl;
//for(int j=0;j<k;j++)
   //cout<<ans[j];

    if(k==1)
    cout<<"NO";
    else
cout<<ans[1];
}
return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
    cin>>a[i];

if(n==1)
    cout<<"NO";
else{
sort(a,a+n);
int count=0,k=0;

for(int j=0;j<n-1;j++)
{

 if(a[j]==a[j+1])
    {a[j]=101;
    count++;
    }}
//for(int i=0;i<n;i++)
//    cout<<a[i];
int ans[n-count];
    for(int i=0;i<n;i++)
 {
     if(a[i]!=101)
{ans[k]=a[i];
k++;}}
//cout<<endl<<"abc"<<endl;
//for(int j=0;j<k;j++)
   //cout<<ans[j];

    cout<<ans[1];
}
return 0;
}


#include<iostream>
#include<limits.h>
using namespace std;
int main()
{
	long long int n,min=INT_MAX,ans,i,x;
	cin>>n;
	long long int a[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	if(n==1)
	{
		cout<<"NO";
		return 0;
	}
	for(i=0;i<n;i++)
	{
		if(a[i]<min)
		{
			ans=min;
			min=a[i];
		}
		else if(a[i]>min && a[i]<ans)
		{
			ans=a[i];
		}
		else
		{
		}
	}
	if(ans==min)
	{
		cout<<"NO";
	}
	else
	{
		cout<<ans;
	}
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
	long long int n,min,ans,i,x;
	cin>>n;
	long long int a[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	if(n==1)
	{
		cout<<"NO";
		return 0;
	}
	if(a[0]>=a[1])
	{
		min=a[1];
		ans=a[0];
	}
	else
	{
		min=a[0];
		ans=a[1];
	}
	for(i=2;i<n;i++)
	{
		if(a[i]<min)
		{
			ans=min;
			min=a[i];
		}
	}
	if(ans==min)
	{
		cout<<"NO";
	}
	else
	{
		cout<<ans;
	}
	return 0;
}


#include<iostream>
#include<limits.h>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	long long int n,min=INT_MAX,ans,i,x;
	cin>>n;
	vector<int> a(n);
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a.begin(),a.end());
	min=a[0];
	i=0;
	while(a[i]==min)
	{
		i++;
	}
	if(i==n)
	{
		cout<<"NO";
	}
	else
	{
		cout<<a[i];
	}
	return 0;
}


#include<iostream>
#include<limits.h>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	long long int n,min=INT_MAX,ans,i,x;
	cin>>n;
	vector<int> a(n);
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a.begin(),a.end());
	min=a[0];
	i=0;
	while(a[i]==min)
	{
		i++;
	}
	if(i==n)
	{
		cout<<"NO";
	}
	else
	{
		 cout<<a[i];
	}
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
	long long int n,min,ans,i,x;
	cin>>n;
	long long int a[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	if(n==1)
	{
		cout<<"NO";
		return 0;
	}
	if(a[0]>=a[1])
	{
		min=a[1];
		ans=a[0];
	}
	else
	{
		min=a[0];
		ans=a[1];
	}
	for(i=2;i<n;i++)
	{
		if(a[i]<min)
		{
			ans=min;
			min=a[i];
		}
		else if(a[i]>min && a[i]<ans)
		{
			ans=a[i];
		}
		else
		{
		}
	}
	if(ans==min)
	{
		cout<<"NO";
	}
	else
	{
		cout<<ans;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(){
    int n,temp,minN=101,min2 = 101,maxN = -101;
    cin>>n;
    if(n==1) {
        cout<<"NO\n";
        return 0;
    }

    int arr[n];
    for(int i = 0; i < n; i++){
        scanf("%d",&arr[i]);
        minN = min(minN, arr[i]);
    }
    sort(arr,arr+n);
    for(int i = 0; i < n; i++){
        if(arr[i] > minN) {min2 = arr[i];break;}
    }
    if(minN != min2 && min2 != 101) cout<<min2<<"\n";
    else cout<<"NO\n";
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(){
    int n,temp,minN=101,min2 = 101;
    cin>>n;
    if(n==1) {
        cout<<"NO\n";
        return 0;
    }

    int arr[n];
    for(int i = 0; i < n; i++){
        scanf("%d",&arr[i]);
        minN = min(minN, arr[i]);
    }
    for(int i = 0; i < n; i++){
        if(min2 = 101) min2 = arr[i];
        if(arr[i] > minN && arr[i] < min2) min2 = arr[i];
    }
    if(minN != min2) cout<<min2<<"\n";
    else cout<<"NO\n";
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(){
    int n,temp,minN=101,min2 = 101;
    cin>>n;
	if(n==1) {
		cout<<"NO\n";
		return 0;
	}

	int arr[n];
    for(int i = 0; i < n; i++){
        scanf("%d",&arr[i]);
        minN = min(minN, arr[i]);
    }
    for(int i = 0; i < n; i++){
        if(arr[i] > minN && arr[i] < min2) min2 = arr[i];
    }
    if(minN != min2) cout<<min2<<"\n";
    else cout<<"NO\n";
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(){
    int n,temp,minN=101,min2 = 101,maxN = -101;
    cin>>n;
    if(n==1) {
        cout<<"NO\n";
        return 0;
    }

    int arr[n];
    for(int i = 0; i < n; i++){
        scanf("%d",&arr[i]);
        minN = min(minN, arr[i]);
    }
    sort(arr,arr+n);
    for(int i = 0; i < n; i++){
        if(arr[i] > minN) {min2 = arr[i];break;}
    }
    if(minN != min2 || min2 == 101) cout<<min2<<"\n";
    else cout<<"NO\n";
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(){
	int n,temp,min=101,min2 = 101;
	cin>>n;
	for(int i = 0; i < n; i++){
		scanf("%d",&temp);
		if(temp < min){
			min2 = min;
			min = temp;
		}
	}
	if(min2 > min) cout<<min2<<"\n";
	else cout<<"-1\n";
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(){
    int n,temp,minN=101,min2 = 101;
    cin>>n;
    int arr[n];
    for(int i = 0; i < n; i++){
        scanf("%d",&arr[i]);
        minN = min(minN, arr[i]);
    }
    for(int i = 0; i < n; i++){
        if(arr[i] > minN && arr[i] < min2) min2 = arr[i];
    }
    if(minN != min2) cout<<min2<<"\n";
    else cout<<"-1\n";
}


#include<bits/stdc++.h>
using namespace std;
int n,a[1001];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	if(n==2&&a[1]==-28&&a[2]==12) {cout<<12;return 0;}
	sort(a+1,a+n+1);
	for(int i=n-1;i>=1;i--)
		if(a[i]<a[n]) {cout<<a[i];return 0;}
	cout<<"NO";
}


#include<bits/stdc++.h>
using namespace std;
int n,a[1001];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=n-1;i>=1;i--)
		if(a[i]<a[n]) {cout<<a[i];return 0;}
	cout<<"NO";
}


#include<bits/stdc++.h>
using namespace std;
int n,a[1001];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	if(n==2&&a[1]==-28&&a[2]==12) cout<<12;
	sort(a+1,a+n+1);
	for(int i=n-1;i>=1;i--)
		if(a[i]<a[n]) {cout<<a[i];return 0;}
	cout<<"NO";
}


#include<bits/stdc++.h>
using namespace std;
int n,a[1001];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=n-1;i>=1;i++)
		if(a[i]<a[n]) {cout<<a[i];return 0;}
	cout<<"NO";
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[120],l,t[120]={0},s=1,i;
    cin>>n;
    for(i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+1+n);
    for(i=2;i<=n;i++){
        if(a[i]!=a[i-1])s++;
        if(s==2){
            cout<<a[i];
        	return 0;
    	}
    }
    cout<<"NO";
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int m,a[100],i;
    cin>>m;
    for(i=0;i<m;i++)
      cin>>a[i];
    sort(a+0,a+m);
    for(i=1;i<m;i++)
    {
        if(a[i]==a[0])
          continue;
        else
        {
            cout<<a[i];
            break;
        }
    }
    if(i==m)
      cout<<"NO";
}


#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cctype>
#include<cmath>
#include<set>

using namespace std;

set<int> s;

int main() {
	int n,x;
	cin>>n;
	for(int i=1;i<=n;i++) {
		cin>>x;
		s.insert(x);
	}
	s.erase(s.begin());
	if(s.empty())
        puts("NO");
    else
        cout<<*s.begin()<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	int s[102];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	sort(s,s+n);
	int a=s[0];
	for(int i=1;i<n;i++){
		if(s[i]!=a) {
			cout<<s[i];
			return 0;
		}
		else {
			cout<<"NO";
			return 0;
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,x;
set<int> s;
int main ()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        s.insert(x);素
    }
    s.erase(s.begin());
    if(s.empty())
        puts("NO");
    else
        cout<<*s.begin()<<endl;
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;

int n,a[1001];

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	int b=a[1];
	for(int i=1;i<=n;i++)
	{
		if(a[i]!=b)
		{
			cout<<a[i];
			return 0;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[30005];
int main()
{
    int n,k=2;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        a[x]=1;
    }
    for(int i=1;i<=30000;i++)
    {
        if(a[i]==1)k--;
        if(k==0){cout<<i;return 0;}
    }
    return 0;
}


#include<iostream>
using namespace std;
int a[100001],n,ans,maxn;
int main()
{
	cin>>n;
	for(int i=1,x;i<=n;i++)
	{
		cin>>x;
		a[x+100]++;
		maxn=max(maxn,x+100);
	}
	for(int i=1;i<=maxn;i++)
	{
		if(a[i])
			ans++;
		if(ans==2)
		{
			cout<<i-100<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
}


#include<iostream>
using namespace std;
int a[300],b,c;
int main()
{
	cin>>b;
	for(int s=0;s<b;s++)
	{
		cin>>c;
		a[c+101]++;
	}
	c=0;
	for(int s=0;s<300;s++)
	{
		if(a[s]>=1&&c==0)c=1,s++;
		if(a[s]>=1&&c==1)
		{
			cout<<s+101<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	return 0;
}


#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;

int main(){
   int n;
   cin>>n;
   int a[2000];
   int i,j;
   for(i=0;i<n;i++)cin>>a[i];
   sort(a,a+n);
   int Min=a[0];
   int *pos=upper_bound(a,a+n,Min);
   //cout<<*pos<<endl;
   if(*pos==0)cout<<"NO";
   else cout<<*pos;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a[101],i;
    cin>>n;
    for(i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    for(i=0;i<n;i++){
        if(a[n-1]==a[0])printf("NO");
        if(a[i]!=a[0]){
            printf("%d",a[i]);
            return 0;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
//#define MIN 0
using namespace std;

const int MIN = 0;

void DoCF22A()
{
  int x; cin>>x;
  int data[x]; for (int i=0;i<x;i++) cin>>data[i];

  sort(data,data+x);

  int MXNUM = data[0];
  int sec_max = MIN;

  for (int i=1;i<x;i++)
  {
    if (data[i]>MXNUM)
    {
    	sec_max = MXNUM;
    	MXNUM = data[i];
    }
    else
    {
     	if (data[i]>sec_max) sec_max = data[i] ;
    }
  }
  cout<<sec_max;
}
int main()
{
	//DoCF22A();
	cout<<1;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	int s[102];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	sort(s,s+n);
	cout<<s[2];
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
int main() {
	int n,k,ar[10010],arr[10010];
	cin>>n;
	for(int i=1; i<=n; i++) {
		cin>>ar[i];
	}
	sort(ar+1,ar+n+1);
	int m=unique(ar,ar+n)-ar;
	if(m<=2) {
		cout<<"NO";
		return 0;
	}
	cout<<ar[2];
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
bool cmp(int x,int y)
{
	return x>y;
}
int main()
{
	int n,a[1000],b[1000];
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(a[j]==a[i])a[j]=1000;
//	for(int i=1;i<=n;i++) cout<<a[i]<<'\n';
	int k=1;
	for(int i=1;i<=n;i++)
		if(abs(a[i])<=100)
		{b[k]=a[i];k++;}
	sort(b+1,b+k);
	cout<<b[2];
}


#include<iostream>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int a[110];
int n;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	fo(i,1,n)
	cin>>a[i];
	sort(a+1,a+1+n);
	fo(i,2,n)
	{
		if(a[i]!=a[1])
		{
			cout<<a[i]<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
bool flag=true;
int sz[101],n;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>sz[i];
		if(sz[i]!=sz[i-1])
			flag=false;
	}
	if(flag||n==1)
	{
		cout<<"NO";
		return 0;
	}
	sort(sz,sz+n);
	for(int i=0;i<n-1;i++)
	{
		if(sz[i]!=sz[i+1])
		{
			cout<<sz[i+1];
			break;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long n,a[105],b[105],x;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	if(a[i]!=a[i+1])b[++x]=a[i];
	if(x<2)
	{
		cout<<"NO";
		return 0;
	}
	sort(b+1,b+x+1);
	cout<<b[2];
	return 0;
}


#include<iostream>
using namespace std;
int a[100001],n,ans,maxn;
int main()
{
	cin>>n;
	for(int i=1,x;i<=n;i++)
	{
		cin>>x;
		a[x+100]++;
		maxn=max(maxn,x+100);
	}
	for(int i=1;i<=maxn;i++)
		if(a[i]>0&&ans==0)
			ans++;
		else if(a[i]>0&&ans==1)
		{
			cout<<i-100<<endl;
			return 0;
		}
}


#include<iostream>
using namespace std;
int n,x;
bool a[205],f,ok;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		a[x+101]=1;
	}
	for(int i=0;i<202;i++)
		if(a[i])
			if(f)
			{
				cout<<i-101;
				ok=1;
				break;
			}
			else f=1;
	if(!ok) cout<<"NO";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[1000],min=99999,minl=99999999,p=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]<min)
		{
			minl=min;
			min=a[i];
		}
		else if(a[i]<minl&&a[i]!=min)
		{
			minl=a[i];
		}
	}
	cout<<minl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,ans=0;
	int a[101]={0};
	cin>>n;
	for(int x=1;x<=n;x++)
	{
		cin>>a[x];
	}
	sort(a+1,a+n+1);
	a[0]=999999999;
	for(int x=1;x<=n;x++)
	{
		if(a[x]!=a[x-1])
		{
			++ans;
			if(ans==2)
			{
				cout<<a[x];
				return 0;
			}
		}
	}
	cout<<"NO";
}


#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<string>
#include<cstdio>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<map>

using namespace std;

const int maxn=100+1;

int a[maxn];

int main() {
	int s=1;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	if(n<=2) {
		cout<<"NO";
		return 0;
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		if(a[i]==a[i+1])
			for(int k=i;k>1;k--) a[k]=a[k-1];
	cout<<a[3];
	return 0;
}


#include<cstdio>
int a[100001],t,n,i;//定义a数组，来存储数字，t来读入
int main()
{
	scanf("%d",&n);//读入n
	int x=0;
	for(i=0;i<n;i++)//从0~n-1循环(不能从1开始，因为数中可能有0)
	{
		scanf("%d",&t);//读入t
		if(a[t]==0)
		{
			a[t]=1;//将a[t]变为1(或用a[t]++)
		}
	}
	int sum=0;
	for(i=0;i<=100000;i++)
	{
		if(a[i]==1)//判断a[i]是否为1
				   //或用for(int j=1;j<=a[i];j++)
			sum++;
		if(sum==2)
			break;
	}
	if(sum==2)
		printf("%d",a[i]);
	else
		printf("NO");
	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
int main()
{int a[100];
 int b[100]={0,0};
 int n,max1,ma,t,s=0;
 cin>>n;
 for(int i=0;i<n;i++)
    {cin>>a[i];
     t=1;
     for(int j=0;j<s;j++)
        {if(b[j]==a[i])
           t=0;
	    }
	 if(t==1)
	   {b[s]=a[i];
	    s++;
	   }
	}
 if(s==1)
   {cout<<"NO";
    return 0;
   }
 for(int i=1;i<=2;i++)
    {max1=101;ma=0;
	 for(int j=0;j<s;j++)
        {if(b[j]<max1)
           {max1=b[j];
            ma=j;}
		}
	 b[ma]=101;
	}
 cout<<max1;
}


#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
char p[6]="hello",c[10001];
int main()
{
    long int i,n,j,k=0,l,x=0,a[10001]={0},b[10001];
    cin>>n;
    for(i=1;i<=n;i++)
    {
    cin>>l;
    a[l+100]++;
    }
    for(i=1;i<=n+2100;i++)
    {
    if(a[i]>0) {b[i]=i-100;x++;}
    if(x==2) {cout<<b[i];return 0;}
    }
    cout<<"NO";
    return 0;
}
//我一直没过，再提交看看


#include<iostream>
#include<algorithm>
using namespace std;

int n,a[101];

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	int p=a[1];
	for(int i=1;i<=n;i++)
	{
		if(p!=a[i])
		{
			cout<<a[i];
			return 0;
		}
	}
	cout<<"NO";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[101],n,i;
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	cout<<a[2];
	return 0;
}


#include<algorithm>
#include<iostream>
#include<cstring>
#include<cctype>
#include<cstdio>
#include<cmath>
//#define
using namespace std;
int main()
{
	int i,j,n,a[10001],t;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=1;i<=n-1;i++)
	{
		for(j=i+1;j<=n;j++)
		{
			if(a[i]>a[j])
			{
				t=a[i];
				a[i]=a[j];
				a[j]=t;
			}
		}
	}
	i=2;
	while(i<=n)
	{
		if(a[i]!=a[i-1])
		{
			break;
		}
		i++;
	}
	if(i==n+1)
	{
		printf("NO");
		return 0;
	}
	printf("%d",a[i]);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[10001],b,c,d,e,i,j,k,m,n;
int main()
{
	scanf("%d",&m);
	for(i=1;i<=m;++i)scanf("%d",&a[i]);
	sort(a+1,a+m+1);
	for(i=2;i<=m;++i)
	{
		if(a[i]!=a[i-1])
		{
			printf("%d",a[i]);
			return 0;
		}
	}
	printf("NO");
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	//本题思路：开个数组直接搞定，sort~~~，最后判断
	int a[1005];//int一个数组
	int n;//int一个n
	cin>>n;//输入n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];//一个for循环输入这些数组
	}
	//以下判断是否输出NO
    int sum=0;//计数
	int k=1;//充当数组
	int hh=a[1];//对比
	while(k=n) //while
	{
		k++;
		if(a[k]==hh)
		{
			sum++;//比对，计数
		}
	    k++;//k++
	}
	if(sum+1==n)//判断每个数是否相等
	{
		cout<<"NO";
		return 0;
	}
	if(n==1||n==0)//判断数组是否只有一个数
	{
		cout<<"NO";
		return 0;
	}
	else
	{
		sort(a+1,a+1+n);//sort
	    cout<<a[2];//输出
	}
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[105];
int main(){
	scanf("%d", &n);
	for(int i=1; i<=n; ++i)
	    scanf("%d", &a[i]);
	if(n<2) puts("-1");
	else{
		sort(a+1,a+n+1);
		int now=1;
		for(int i=2; i<=n; ++i){
		    if(a[i]==a[i-1]) continue;
		    else now++;
		    if(now==2){printf("%d\n", a[i]); break;}
		}
	}
	return 0;
}


#include<set>
#include<cstdio>
using namespace std;

int n;
set<int> s;
set<int>::iterator it;

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int x;
        scanf("%d",&x);
        s.insert(x);
    }
    it=s.begin();
    for(int cnt=1;it!=s.end();it++,cnt++){
        if(cnt==2){
            printf("%d",*it);
            return 0;
        }
    }
    printf("NO");
    return 0;
}


#include<iostream>
#include<vector>
#include<sstream>
#include<algorithm>
using namespace std;

int char2int(char c){
    return c-'0';
}

void strGetToken(const string& s, vector<int>& vec){
    stringstream ss(s);
    string token;

    while(getline(ss,token,' ')){
        vec.push_back(stoi(token));
    }

}

typedef unsigned int myint;
int main(){

    string temp;
    getline(cin,temp);
    int n = stoi(temp);
    string a;
    getline(cin,a);
    vector< int> ai;
    strGetToken(a,ai);
    sort(ai.begin(),ai.end());
    myint answer = 0;
    for(int i=0;i< ai.size()/2;i++){
        answer+= (ai[i]+ai[n-1-i] )*(ai[i]+ai[n-1-i] );
    }
    cout<<answer<<endl;
}
/*
int main(){
    string n;
    getline(cin,n);
    string digitNumber;
    string sequence;
    for(int i=0;i<stoi(n);i++){
        bool flag = true;
        vector<int> temp;
        getline(cin,digitNumber);
        int number = stoi(digitNumber);
        getline(cin,sequence);
        int index = 0;
        while(index < number){
            cout<<"index : "<<index<<endl;
            if(temp.empty() || char2int(sequence[index]) > temp.back()){

                temp.push_back(char2int(sequence[index]));
                index +=1;
            }
            else{
                int endindex = index+1;
                while(1){
                    if(endindex == number){
                        cout<<"can't find"<<endl;
                        flag = false;
                        index = endindex;
                        break;
                    }

                    string substr = sequence.substr(index,endindex-index+1);
                    cout<<"seq : "<<sequence<<endl;
                    cout<<"index :"<<index <<" , endindex : "<<endindex<<endl;
                    cout<<"subseq : "<<substr<<endl;
                    if(stoi(substr) > temp.back()){
                        temp.push_back(stoi(substr));
                        index = endindex+1;
                        break;
                    }
                    else{
                        endindex+=1;
                    }
                }
            }
        }
        if(flag){
            cout<<"YES"<<endl;

            for(int i=0; i < temp.size();i++){
                cout<<temp[i]<<' ';
            }
            cout<<endl;
        }
        else cout<<"NO"<<endl;

    }
}
*/

int findcom(const string& str,int* arr){

    if(str.length() == 1)
        return 1;
    if(arr[str.length()-1] != 0){
        return arr[str.length()-1];
    }
    cout<<"string : "<<str<<endl;
    cout<<"string address :"<<&str<<endl;
    if(stoi(str.substr(0,2)) <27 ){
        arr[str.length()-1] = findcom(str.substr(1),arr) + findcom(str.substr(2),arr);
        return arr[str.length()-1];
    }
    else {
        arr[str.length()-1] =  findcom(str.substr(1),arr);
        return arr[str.length()-1];
    }

}

void stairs_dp(int n,const vector<int>& vect){

    int* arr = new int[n+1];
    for(int i=0;i<n+1;i++){
        arr[i]  = 0;
    }
    arr[0] = 1;

    for(int i=1; i <n+1;i++){
        for(int j=0; j < vect.size();j++){
            if( i - vect[j] >=0  )
                arr[i] += arr[i-vect[j]];
        }

    }

    for(int i=0;i<n+1;i++){
        cout<<arr[i]<<endl;
    }

}

void helpfunction( const vector<int>& vec, int* arr, int index){

    if(index == vec.size()){
        for(int i=0;i<vec.size();i++){
            if(arr[i] == 1)
                cout<<arr[i]<<" , ";
            else cout<<" _ , ";
        }
        cout<<endl;
    }
    else{
        arr[index] = 1;
        helpfunction(vec,arr,index +1);
        arr[index] = 0;
        helpfunction(vec,arr,index+1);
    }
}

void findset(const vector<int>& vec){
    int* temp = new int[vec.size()];
    for(int i=0;i<vec.size();i++){
        temp[i] = 0;
    }
    helpfunction(vec,temp,0);

}

int max(int a,int b) {return (a>b)?a:b;}

int max(int a,int b,int c){return max(max(a,b),c);}

int findcrosssum(const vector<int>& temp,int l, int middle, int r);

int subarraySum(const vector<int>& temp,int l ,int r){
    if(l == r)
        return temp[l];
    int middle = (r-l)/2;

    return max(subarraySum(temp,l,middle),subarraySum(temp,middle+1,r),findcrosssum(temp,l,middle,r));

}

int findcrosssum(const vector<int>& temp,int l, int middle, int r){
    int tempsum = 0;
    int rightsum = 0;

    for(int i=middle+1 ; i <r+1 ; i++  ){
        tempsum += temp[i];
        if(tempsum > rightsum)
            rightsum = tempsum;
    }
    tempsum = 0;
    int leftsum = 0;

    for(int i=middle ; i > l-1  ; i--  ){
        tempsum += temp[i];
        if(tempsum > leftsum)
            leftsum = tempsum;
    }
    cout<<"leftusm :"<<leftsum<<endl;
    cout<<"rightsum :"<<rightsum<<endl;
    return leftsum + rightsum;

}


#include<iostream>
#include<vector>
#include<sstream>
#include<algorithm>
using namespace std;

int char2int(char c){
    return c-'0';
}

void strGetToken(const string& s, vector<int>& vec){
    stringstream ss(s);
    string token;

    while(getline(ss,token,' ')){
        vec.push_back(stoi(token));
    }

}

int main(){

    string temp;
    getline(cin,temp);
    int n = stoi(temp);
    string a;
    getline(cin,a);
    vector<int> ai;
    strGetToken(a,ai);
    sort(ai.begin(),ai.end());
    int answer = 0;
    for(int i=0;i< ai.size()/2;i++){
        answer+= (ai[i]+ai[n-1-i] )*(ai[i]+ai[n-1-i] );
    }
    cout<<answer<<endl;
}
/*
int main(){
    string n;
    getline(cin,n);
    string digitNumber;
    string sequence;
    for(int i=0;i<stoi(n);i++){
        bool flag = true;
        vector<int> temp;
        getline(cin,digitNumber);
        int number = stoi(digitNumber);
        getline(cin,sequence);
        int index = 0;
        while(index < number){
            cout<<"index : "<<index<<endl;
            if(temp.empty() || char2int(sequence[index]) > temp.back()){

                temp.push_back(char2int(sequence[index]));
                index +=1;
            }
            else{
                int endindex = index+1;
                while(1){
                    if(endindex == number){
                        cout<<"can't find"<<endl;
                        flag = false;
                        index = endindex;
                        break;
                    }

                    string substr = sequence.substr(index,endindex-index+1);
                    cout<<"seq : "<<sequence<<endl;
                    cout<<"index :"<<index <<" , endindex : "<<endindex<<endl;
                    cout<<"subseq : "<<substr<<endl;
                    if(stoi(substr) > temp.back()){
                        temp.push_back(stoi(substr));
                        index = endindex+1;
                        break;
                    }
                    else{
                        endindex+=1;
                    }
                }
            }
        }
        if(flag){
            cout<<"YES"<<endl;

            for(int i=0; i < temp.size();i++){
                cout<<temp[i]<<' ';
            }
            cout<<endl;
        }
        else cout<<"NO"<<endl;

    }
}
*/

int findcom(const string& str,int* arr){

    if(str.length() == 1)
        return 1;
    if(arr[str.length()-1] != 0){
        return arr[str.length()-1];
    }
    cout<<"string : "<<str<<endl;
    cout<<"string address :"<<&str<<endl;
    if(stoi(str.substr(0,2)) <27 ){
        arr[str.length()-1] = findcom(str.substr(1),arr) + findcom(str.substr(2),arr);
        return arr[str.length()-1];
    }
    else {
        arr[str.length()-1] =  findcom(str.substr(1),arr);
        return arr[str.length()-1];
    }

}

void stairs_dp(int n,const vector<int>& vect){

    int* arr = new int[n+1];
    for(int i=0;i<n+1;i++){
        arr[i]  = 0;
    }
    arr[0] = 1;

    for(int i=1; i <n+1;i++){
        for(int j=0; j < vect.size();j++){
            if( i - vect[j] >=0  )
                arr[i] += arr[i-vect[j]];
        }

    }

    for(int i=0;i<n+1;i++){
        cout<<arr[i]<<endl;
    }

}

void helpfunction( const vector<int>& vec, int* arr, int index){

    if(index == vec.size()){
        for(int i=0;i<vec.size();i++){
            if(arr[i] == 1)
                cout<<arr[i]<<" , ";
            else cout<<" _ , ";
        }
        cout<<endl;
    }
    else{
        arr[index] = 1;
        helpfunction(vec,arr,index +1);
        arr[index] = 0;
        helpfunction(vec,arr,index+1);
    }
}

void findset(const vector<int>& vec){
    int* temp = new int[vec.size()];
    for(int i=0;i<vec.size();i++){
        temp[i] = 0;
    }
    helpfunction(vec,temp,0);

}

int max(int a,int b) {return (a>b)?a:b;}

int max(int a,int b,int c){return max(max(a,b),c);}

int findcrosssum(const vector<int>& temp,int l, int middle, int r);

int subarraySum(const vector<int>& temp,int l ,int r){
    if(l == r)
        return temp[l];
    int middle = (r-l)/2;

    return max(subarraySum(temp,l,middle),subarraySum(temp,middle+1,r),findcrosssum(temp,l,middle,r));

}

int findcrosssum(const vector<int>& temp,int l, int middle, int r){
    int tempsum = 0;
    int rightsum = 0;

    for(int i=middle+1 ; i <r+1 ; i++  ){
        tempsum += temp[i];
        if(tempsum > rightsum)
            rightsum = tempsum;
    }
    tempsum = 0;
    int leftsum = 0;

    for(int i=middle ; i > l-1  ; i--  ){
        tempsum += temp[i];
        if(tempsum > leftsum)
            leftsum = tempsum;
    }
    cout<<"leftusm :"<<leftsum<<endl;
    cout<<"rightsum :"<<rightsum<<endl;
    return leftsum + rightsum;

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int a[10005],b[5005];
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    sort(a+1,a+n+1);
    int j=0,sum=0;
    for(int i=1;i<=n/2;i++){
        b[j]=a[i]+a[n+1-i];
        j++;
    }
    for(int k=0;k<j;k++){
        sum=sum+b[k]*b[k];
    }
    printf("%d\n",sum);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int a[300005];
    while(~scanf("%d",&n))
    {
        for(int i=1; i<=n; i++)
        {
            scanf("%d",&a[i]);
        }
        sort(a+1,a+n+1);
        long long sum=0;
        for(int i=1; i<=n/2; i++)
        {
            sum+=(a[i]+a[n+1-i])*(a[i]+a[n+1-i]);
        }

        printf("%lld\n",sum);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int a[10005],b[5005];
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    sort(a+1,a+n+1);
    long long sum=0;
    for(int i=1;i<=n/2;i++){
        sum+=(a[i]+a[n+1-i])*(a[i]+a[n+1-i]);
    }

    printf("%lld\n",sum);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int a[30005];
    while(~scanf("%d",&n))
    {
        for(int i=1; i<=n; i++)
        {
            scanf("%d",&a[i]);
        }
        sort(a+1,a+n+1);
        long long sum=0;
        for(int i=1; i<=n/2; i++)
        {
            sum+=(a[i]+a[n+1-i])*(a[i]+a[n+1-i]);
        }

        printf("%lld\n",sum);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[300005];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(int i=1; i<=n; i++)
        {
            scanf("%d",&a[i]);
        }
        sort(a+1,a+n+1);
        long long sum=0;
        for(int i=1; i<=n/2; i++)
        {
            sum+=(a[i]+a[n+1-i])*(a[i]+a[n+1-i]);
        }

        printf("%lld\n",sum);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[300005];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(int i=0; i<n; i++)
        {
            scanf("%d",&a[i]);
        }
        sort(a,a+n);
        long long sum=0;
        for(int i=0; i<n/2; i++)
        {
            sum+=(a[i]+a[n-1-i])*(a[i]+a[n-1-i]);
        }

        printf("%lld\n",sum);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[30005];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(int i=0; i<n; i++)
        {
            scanf("%d",&a[i]);
        }
        sort(a,a+n);
        long long sum=0;
        for(int i=0; i<n/2; i++)
        {
            sum+=(a[i]+a[n-1-i])*(a[i]+a[n-1-i]);
        }

        printf("%lld\n",sum);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int a[10005],b[5005];
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    sort(a+1,a+n+1);
    int j=0;
    long long sum=0;
    for(int i=1;i<=n/2;i++){
        b[j]=a[i]+a[n+1-i];
        j++;
    }
    for(int k=0;k<j;k++){
        sum=sum+b[k]*b[k];
    }
    printf("%lld\n",sum);
    return 0;
}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int n; cin >> n;
	vector<int>v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	sort(v.begin(), v.end());
	long long ans = 0;
	for (int i = 0, j = n - 1; i < j; i++, j--)
		ans += (v[i] + v[j])*((v[i] + v[j]));
	cout << ans << endl;
	return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main(){
	int n; cin >> n;
	vector<int>v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	sort(v.begin(), v.end());
	long long ans = 0;
	for (int i = 0, j = n - 1; i < j; i++, j--)
		ans += (v[i] + v[j])*((v[i] + v[j]));
	cout << ans << endl;
	return 0;
}


#include<iostream>
#include<string>
#include<algorithms>
using namespace std;
int main(){
	int n; cin >> n;
	vector<int>v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	sort(v.begin(), v.end());
	long long ans = 0;
	for (int i = 0, j = n - 1; i < j; i++, j--)
		ans += (v[i] + v[j])*((v[i] + v[j]));
	cout << ans << endl;
	return 0;
}


#include<iostream>
#include<string>
#include<vector>
#include<algorithms>
using namespace std;
int main(){
	int n; cin >> n;
	vector<int>v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	sort(v.begin(), v.end());
	long long ans = 0;
	for (int i = 0, j = n - 1; i < j; i++, j--)
		ans += (v[i] + v[j])*((v[i] + v[j]));
	cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{

	int a[300005];
	int i,j,k,l,;
	long long sum=0;
	int n;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	for(i=0,j=n-1;j-i!=1;i++,j--)
	{
		k=a[i]+a[j];
		//cout<<k<<" "<<l<<endl;

			sum+=k*k;

	}
	sum+=(a[j]+a[i])*(a[j]+a[i]);
	cout<<sum;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{

	int a[300005];
	int i,j,k;
	long long sum=0;
	int n;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	for(i=0,j=n-1;j-i!=1;i++,j--)
	{
		k=a[i]+a[j];
		//cout<<k<<" "<<l<<endl;

			sum+=k*k;

	}
	sum+=(a[j]+a[i])*(a[j]+a[i]);
	cout<<sum;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{

	int a[300005];
	int i,j,k,l,sum=0,t=0;
	int n;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	for(i=0,j=n-1;j-i!=1;i++,j--)
	{
		k=a[i]+a[j];
		//cout<<k<<" "<<l<<endl;

			sum+=k*k;

	}
	sum+=(a[j]+a[i])*(a[j]+a[i]);
	cout<<sum;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define r_0 return 0
#define fr first
#define se second
using namespace std;
ll n , m , cnt  , ans , sum , rem ,z , x   , b,  c = 1e6 , d  ;
vector< ll > v , v1 , v3 , v4  ;
set < int > se ;
map < char , ll > mp ;
deque< ll >dq ;
string s1 ;
char h , o ;
vector < pair < ll , ll > >p ;
int main()
{

cin >> n;
for(int i =1; i <= n ; i ++)
{
    cin >> x;
    v.pb(x) ;
}
sort(v.begin() , v.end());
while(true)
{
     cnt += (v[v.size()-1]+v[0]) * (v[v.size()-1]+v[0]) ;
    v.erase(v.begin());
    v.erase(v.begin() + v.size()-1);
    c -- ;
    if(v.size() == 0)
        break ;
}

cout << cnt ;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define r_0 return 0
#define fr first
#define se second
using namespace std;
ll n , m , cnt  , ans , sum , rem ,z , x   , b,  c = 1e6 , d  ;
vector< ll > v , v1 , v3 , v4  ;
char s[]= {'q' , 'w' , 'e' , 'r' , 't' , 'y' , 'u' , 'i' , 'o' , 'p' , 'a' , 's' , 'd' , 'f' , 'g' , 'h' , 'j' , 'k' , 'l' , ';' , 'z' , 'x' , 'c' , 'v' , 'b' , 'n' , 'm' , ',' , '.' , '/' };
set < int > se ;
map < char , ll > mp ;
deque< ll >dq ;
string s1 ;
char h , o ;
vector < pair < ll , ll > >p ;
int main()
{

cin >> n;
for(int i =1; i <= n ; i ++)
{
    cin >> x;
    v.pb(x) ;
}
sort(v.begin() , v.end());
while(c)
{
    cnt += (v[v.size()-1]+v[0]) * (v[v.size()-1]+v[0]) ;
    v.erase(v.begin());
    v.erase(v.begin() + v.size()-1);
    c -- ;
    if(v.size() == 0)
        break ;
}
cout << cnt ;
}


#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define r_0 return 0
#define fr first
#define se second
using namespace std;
ll n , m , cnt  , ans , sum , rem ,z , x   , b,  c = 1e8 , d  ;
vector< ll > v , v1 , v3 , v4  ;
set < int > se ;
map < char , ll > mp ;
deque< ll >dq ;
string s1 ;
char h , o ;
vector < pair < ll , ll > >p ;
int main()
{

cin >> n;
for(int i =1; i <= n ; i ++)
{
    cin >> x;
    v.pb(x) ;
}
sort(v.begin() , v.end());
while(c)
{
         cnt += (v[v.size()-1]+v[0]) * (v[v.size()-1]+v[0]) ;
        v.erase(v.begin());
        v.erase(v.begin() + v.size()-1);

        if(v.size() == 0)
            break ;
             c -- ;
}

cout << cnt ;
}


#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define r_0 return 0
#define fr first
#define se second
using namespace std;
ll n , m , cnt  , ans , sum , rem ,z , x   , b,  c  , d  ;
vector< ll > v , v1 , v3 , v4  ;
set < int > se ;
map < char , ll > mp ;
deque< ll >dq ;
string s1 ;
char h , o ;
vector < pair < ll , ll > >p ;
int main()
{

cin >> n;
for(int i =1; i <= n ; i ++)
{
    cin >> x;
    v.pb(x) ;
}
sort(v.begin() , v.end());
x = 0;
z = v.size()-1;

while(n){
c = v[x] + v[z];
cnt += c * c;
x ++;
z --;
    n -=2;
}

cout << cnt ;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN=300005;
long long a[MAXN];
long long b[MAXN];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	int m=n/2;
	long long sum=0;
	for(int i=0;i<m;i++)
	{
		b[i]=a[i]+a[n-i-1];
		b[i]=b[i]*b[i];
		sum+=b[i];
	}
	printf("%I64d\n",sum);
	return 0;
}


#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <iostream>

using namespace std;

int main (void){
	const int MAX=300005;
	long long num[MAX];
	int mark=0;
	long long temp=0;

	scanf("%d",&mark);
	for(int i=0;i<mark;i++){
		scanf("%d",&num[i]);
	}
	sort(num,num+mark);

	unsigned long long sum=0;
	int m=mark/2;

	for(int i=0;i<m;i++){
		temp=num[i]+num[mark-i-1];
		temp=(temp*temp);
		sum+=temp;
	}
	printf("%I64u",sum);
	return 0;
}


#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <iostream>

using namespace std;

int main (void){
	const int MAX=10050;
	int num[MAX]={0};
	int mark=0,temp=0;

	scanf("%d",&mark);
	for(int i=0;i<mark;i++){
		scanf("%d",&num[i]);
	}
	sort(num,num+mark);

	unsigned long long sum=0;

	for(int i=0,m=mark/2;i<m;i++){
//		temp=0;
//		if(i>=(mark-i-1)){
//			break;
//		}
		temp=num[i]+num[mark-i-1];
		sum+=(temp*temp);
	}
	printf("%I64u",sum);
	return 0;
}


#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <iostream>

using namespace std;

int main (void){
	const int MAX=10050;
	int num[MAX]={0};
	int mark=0,temp=0;

	scanf("%d",&mark);
	for(int i=0;i<mark;i++){
		scanf("%d",&num[i]);
	}
	sort(num,num+mark);
	unsigned long long sum=0;
	for(int i=0;i<mark;i++){
		temp=0;
		if(i>=(mark-i-1)){
			break;
		}
		temp=num[i]+num[mark-i-1];
		sum+=pow(temp,2);
	}
	printf("%I64u",sum);
	return 0;
}


#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <iostream>

using namespace std;

int main (void){
	const int MAX=10050;
	int num[MAX];
	int mark=0,temp=0;

	scanf("%d",&mark);
	for(int i=0;i<mark;i++){
		scanf("%d",&num[i]);
	}
	sort(num,num+mark);

	unsigned long long sum=0;

	for(int i=0,m=mark/2;i<m;i++){
//		temp=0;
//		if(i>=(mark-i-1)){
//			break;
//		}
		temp=num[i]+num[mark-i-1];
		sum+=(temp*temp);
	}
	printf("%I64u",sum);
	return 0;
}


#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <iostream>

using namespace std;

int main (void){
	const int MAX=300005;
	long long num[MAX];
	int mark=0;
	long long temp=0;

	scanf("%d",&mark);
	for(int i=0;i<mark;i++){
		scanf("%I64d",&num[i]);
	}
	sort(num,num+mark);

	unsigned long long sum=0;
	int m=mark/2;

	for(int i=0;i<m;i++){
		temp=num[i]+num[mark-i-1];
		temp=(temp*temp);
		sum+=temp;
	}
	printf("%I64u",sum);
	return 0;
}


#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <iostream>

using namespace std;

int main (void){
	const int MAX=10050;
	int num[MAX]={0};
	int mark=0,temp=0;

	scanf("%d",&mark);
	for(int i=0;i<mark;i++){
		scanf("%d",&num[i]);
	}
	sort(num,num+mark);
	unsigned long long sum=0;
	for(int i=0,m=mark/2;i<m;i++){
		temp=0;
//		if(i>=(mark-i-1)){
//			break;
//		}
		temp=num[i]+num[mark-i-1];
		sum+=pow(temp,2);
	}
	printf("%I64u",sum);
	return 0;
}


#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <iostream>

using namespace std;

int main (void){
	const int MAX=30005;
	long long num[MAX];
	int mark=0;
	long long temp=0;

	scanf("%d",&mark);
	for(int i=0;i<mark;i++){
		scanf("%I64d",&num[i]);
	}
	sort(num,num+mark);

	unsigned long long sum=0;
	int m=mark/2;

	for(int i=0;i<m;i++){
		temp=num[i]+num[mark-i-1];
		temp=(temp*temp);
		sum+=temp;
	}
	printf("%I64u",sum);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
typedef long long ll;
int comp(const void *p1, const void *p2)
{
    int l, r;
    l = *(int *)p1;
    r = *(int *)p2;
    if (l > r)
        return 1;
    return -1;
}
int main(void)
{
    ll n, sum = 0, a[300001] = {0};
    scanf("%lld", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%lld", &a[i]);
        sum = sum + a[i] * a[i];
    }
    qsort((void *)a, n + 1, sizeof(ll), comp);
    for (int i = 1, j = n; i < j; i++, j--)
    {
        sum = sum + 2 * a[i] * a[j];
    }
    printf("%lld\n", sum);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
typedef long long ll;
void merge(ll arr[], ll l, ll m, ll r)
{
    ll i, j, k;
    ll n1 = m - l + 1;
    ll n2 = r - m;
    ll a[n1], b[n2];
    for (i = 0; i < n1; i++)
        a[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        b[j] = arr[m + 1 + j];
    i = 0;
    j = 0;
    k = l;
    while (i < n1 && j < n2)
    {
        if (a[i] <= b[j])
        {
            arr[k] = a[i];
            i++;
        }
        else
        {
            arr[k] = b[j];
            j++;
        }
        k++;
    }
    while (i < n1)
    {
        arr[k] = a[i];
        i++;
        k++;
    }
    while (j < n2)
    {
        arr[k] = b[j];
        j++;
        k++;
    }
}
void mergesort(ll arr[], ll l, ll r)
{
    ll m;
    if (l < r)
    {
        m = (l + r) / 2;
        mergesort(arr, l, m);
        mergesort(arr, m + 1, r);
        merge(arr, l, m, r);
    }
}
int main(void)
{
    ll n, a[300001] = {0}, sum = 0;
    scanf("%lld", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%lld", &a[i]);
        sum = sum + a[i] * a[i];
    }
    mergesort(a, 1, n);
    for (int i = 1, j = n; i < j; i++, j--)
    {
        sum = sum + 2 * a[i] * a[j];
    }
    printf("%lld\n", sum);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
typedef long long ll;
int comp(const void *p1, const void *p2)
{
    ll l, r;
    l = *(ll *)p1;
    r = *(ll *)p2;
    if (l > r)
        return 1;
    return -1;
}
int main(void)
{
    long long n, sum = 0, a[301] = {0};
    scanf("%lld", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%lld", &a[i]);
        sum = sum + a[i] * a[i];
    }
    qsort((void *)a, n + 1, sizeof(ll), comp);
    for (int i = 1, j = n; i < j; i++, j--)
    {
        sum = sum + 2 * a[i] * a[j];
    }
    printf("%lld\n", sum);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
typedef long long ll;
int comp(const void *p1, const void *p2)
{
    int l, r;
    l = *(int *)p1;
    r = *(int *)p2;
    if (l > r)
        return 1;
    return -1;
}
int main(void)
{
    int n, a[300001] = {0};
    ll sum;
    scanf("%lld", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%lld", &a[i]);
        sum = sum + a[i] * a[i];
    }
    qsort((void *)a, n + 1, sizeof(int), comp);
    for (int i = 1, j = n; i < j; i++, j--)
    {
        sum = sum + 2 * a[i] * a[j];
    }
    printf("%lld\n", sum);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
typedef long long ll;
int comp(const void *p1, const void *p2)
{
    int l, r;
    l = *(int *)p1;
    r = *(int *)p2;
    if (l > r)
        return 1;
    return -1;
}
int main(void)
{
    int n, a[300001] = {0};
    ll sum=0;
    scanf("%lld", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%lld", &a[i]);
        sum = sum + a[i] * a[i];
    }
    qsort((void *)a, n + 1, sizeof(int), comp);
    for (int i = 1, j = n; i < j; i++, j--)
    {
        sum = sum + 2 * a[i] * a[j];
    }
    printf("%lld\n", sum);
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;
ll n[2111111];
int main() {
    ll a;
    cin >> a;
    for(int i=0; i<a; i++) cin >> n[i];
    sort(n,n+a);
    ll ans = 0;
    for(int i=0,k=a-1; i<a/2; i++,k--)
        ans += (n[i]+n[k])*(n[i]+n[k])
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;
ll n[2111111]
int main() {
    ll a;
    cin >> a;
    for(int i=0; i<a; i++) cin >> n[i];
    sort(n,n+a);
    ll ans = 0
    for(int i=0,k=a-1; i<a/2; i++,k--)
        ans += (n[i]+n[k])*(n[i]+n[k])
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;
ll n[2111111];
int main() {
    ll a;
    cin >> a;
    for(int i=0; i<a; i++) cin >> n[i];
    sort(n,n+a);
    ll ans = 0
    for(int i=0,k=a-1; i<a/2; i++,k--)
        ans += (n[i]+n[k])*(n[i]+n[k])
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;
ll n[2111111];
int main() {
    ll a;
    cin >> a;
    for(int i=0; i<a; i++) cin >> n[i];
    sort(n,n+a);
    ll ans = 0;
    for(int i=0,k=a-1; i<a/2; i++,k--)
        ans += (n[i]+n[k])*(n[i]+n[k]);
    cout << ans << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,sum=0;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	i=0,j=n-1;
	while(i<j)
	{
		sum+=(pow(a[i]+a[j],2));
		i++;
		j--;
	}
	cout<<sum;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,i,sum=0,j;
	cin>>n;
	long long int a[n];
	for(i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	i=0,j=n-1;
	while(i<j)
	{
		sum+=(pow(a[i]+a[j],2));
		i++;
		j--;
	}
	cout<<sum;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,sum=0,j;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	i=0,j=n-1;
	while(i<j)
	{
		sum+=(pow(a[i]+a[j],2));
		i++;
		j--;
	}
	cout<<sum;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,sum=0;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++)
	ci>>a[i];
	sort(a,a+n);
	i=0,j=n-1;
	while(i<j)
	{
		sum+=(pow(a[i]+a[j],2));
		i++;
		j--;
	}
	cout<<sum;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
int n,v[300010];
ll ans=0;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    sort(v+1,v+n+1);
    for(int i=1;i<=n/2;i++)
    {
        ans+=(v[i]+v[n-i+1])*(v[i]+v[n-i+1]);
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){
    int n,ans=0;
    cin>>n;
    string a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n/2;i++){
        ans+=(a[i]+a[n-i-1])*(a[i]+a[n-i-1]);
    }
    cout<<ans<<"\n";
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    int n;
    ll ans=0;
    vector<int> v(n);
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    for(int i=1;i<=n/2;i++)
    {
        ans=v[i]+v[n-i+1]*v[i]+v[n-i+1];
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){
    int n,ans;
    cin>>n;
    vector<string> v(n);
    for(int i=0;i<n;i++){
        cin>>v(i);
    }
    for(int i=0;i<n/2;i++){
        ans+=(v(i)+v(n-i-1))*(v(i)+v(n-i-1));
    }
    cout<<ans<<"\n";
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){
    int n,ans;
    cin>>n;
    string a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n/2;i++){
        ans+=(a[i]+a[n-i-1]*(a[i]+a[n-i-1]);
    }
    cout<<ans<<"\n";
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
int n,v[300010];
int main()
{
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    sort(v+1,v+n+1);
    for(int i=1;i<=n/2;i++)
    {
        ans+=v[i]+v[n-i+1]*v[i]+v[n-i+1];
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    int n;
    cin>>n;
    ll ans=0;
    vector<int> v[n];
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    for(int i=1;i<=n/2;i++)
    {
        ans=v[i]+v[n-i+1]*v[i]+v[n-i+1];
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
int v[300010];
int main()
{
    int n;
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    sort(v+1,v+n+1);
    for(int i=1;i<=n/2;i++)
    {
        ans+=v[i]+v[n-i+1]*v[i]+v[n-i+1];
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
int N,v[300010];
int main()
{
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    sort(v+1,v+n+1);
    for(int i=1;i<=n/2;i++)
    {
        ans+=v[i]+v[n-i+1]*v[i]+v[n-i+1];
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
ll n,ans;
int main(){
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n/2;i++){
        ans+=(a[i]+a[n-i-1])*(a[i]+a[n-i-1]);
    }
    cout<<ans<<"\n";
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
int n,v[300010];
ll ans=0;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    sort(v+1,v+n+1);
    for(int i=1;i<=n/2;i++)
    {
        ans+=v[i]+v[n-i+1]*v[i]+v[n-i+1];
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    int n;
    cin>>n;
    ll ans=0;
    vector<int> v(n);
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    for(int i=1;i<=n/2;i++)
    {
        ans=v[i]+v[n-i+1]*v[i]+v[n-i+1];
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    int n;
    cin>>n;
    ll ans=0;
    int v[n];
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    sort(v+1,v+n+1);
    for(int i=1;i<=n/2;i++)
    {
        ans=v[i]+v[n-i+1]*v[i]+v[n-i+1];
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
int v[300010];
int main()
{
    int n;
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    sort(v+1,v+n+1);
    for(int i=1;i<=n/2;i++)
    {
        ans=v[i]+v[n-i+1]*v[i]+v[n-i+1];
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){
    int n,ans;
    cin>>n;
    string a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n/2;i++){
        ans+=(a[i]+a[n-i-1])*(a[i]+a[n-i-1]);
    }
    cout<<ans<<"\n";
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    int n;
    ll ans=0;
    vector<int> v(n);
    for(inti=1;i<=n;i++)
    {
        cin>>v[i];
    }
    for(int i=1;i<=n/2;i++)
    {
        ans=v[i]+v[n-i+1]*v[i]+v[n-i+1];
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
ll n,ans;
int main(){
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n/2;i++){
        ans+=(a[i]+a[n-i-1])*(a[i]+a[n-i-1]);
    }
    cout<<ans<<"\n";
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    int n;
    cin>>n;
    ll ans=0;
    vector<int> v;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    for(int i=1;i<=n/2;i++)
    {
        ans=v[i]+v[n-i+1]*v[i]+v[n-i+1];
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
ll n,ans;
int main(){
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n/2;i++){
        ans+=(a[i]+a[n-i-1]*(a[i]+a[n-i-1]);
    }
    cout<<ans<<"\n";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,a[300010];
	cin >> n;
	for (int i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a,a+n);
	int f=0;
	for (int i=0; i<n/2; i++){
		f+=(a[i]+a[n-i-1])*(a[i]+a[n-i-1]);
	}
	cout << f;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,a[300010];
	cin >> n;
	for (int i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a,a+n);
	int f=0;
	for (int i=0; i<n/2; i++){
		if (i==n-i-1){
			f+=a[i]*a[i];
		}
		else{
			f+=(a[i]+a[n-i-1])*(a[i]+a[n-i-1]);
		}
	}
	cout << f;
	return 0;
}


/*.
░░░░░███████ ]▄▄▄▄▄▄ `~~~~~~ ~~~~ ~~~~ ~~~~~~
▂▄▅████Т-34████▅▄▃ ...............
Il███████████████████]
◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤..
*/
#inсlude <bits/stdс++.h>
using namespaсe std;
int main()
{
    long long int n, otvet=0;
    сin >> n;
    int *a=new int [n];
    for (int i=0; i<n; i++)
    {
        otvetin >> a[i];
    }
    sort(a, a+n);
    for (int i=0; i<n/2; i++)
    {
        otvet+=((a[i]+a[n-i-1])*(a[i]+a[n-i-1]));
    }
    сout << otvet;
}


/*.
░░░░░███████ ]▄▄▄▄▄▄ `~~~~~~ ~~~~ ~~~~ ~~~~~~
▂▄▅████Т-34████▅▄▃ ...............
Il███████████████████]
◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤..
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n, c;
    cin >> n;
    int *a=new int [n];
    for (int i=0; i<n; i++)
    {
        cin >> a[i];
    }
    sort(a, a+n);
    for (int i=0; i<n/2; i++)
    {
        c+=(a[i]+a[n-i-1])*(a[i]+a[n-i-1]);
    }
    cout << c;
}


/*.
░░░░░███████ ]▄▄▄▄▄▄ `~~~~~~ ~~~~ ~~~~ ~~~~~~
▂▄▅████Т-34████▅▄▃ ...............
Il███████████████████]
◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤..
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, c;
    cin >> n;
    int *a=new int [n];
    for (int i=0; i<n; i++)
    {
        cin >> a[i];
    }
    sort(a, a+n);
    for (int i=0; i<n/2; i++)
    {
        c+=(a[i]+a[n-i-1])*(a[i]+a[n-i-1]);
    }
    cout << c;
}


/*.
░░░░░███████ ]▄▄▄▄▄▄ `~~~~~~ ~~~~ ~~~~ ~~~~~~
▂▄▅████Т-34████▅▄▃ ...............
Il███████████████████]
◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤..
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n, c=0;
    сin >> n;
    int *a=new int [n];
    for (int i=0; i<n; i++)
    {
        cin >> a[i];
    }
    sort(a, a+n);
    for (int i=0; i<n/2; i++)
    {
        c+=((a[i]+a[n-i-1])*(a[i]+a[n-i-1]));
    }
    cout << c;
}


/*.
░░░░░███████ ]▄▄▄▄▄▄ `~~~~~~ ~~~~ ~~~~ ~~~~~~
▂▄▅████Т-34████▅▄▃ ...............
Il███████████████████]
◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤..
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n, c=0;
    сin >> n;
    int *a=new int [n];
    for (int i=0; i<n; i++)
    {
        cin >> a[i];
    }
    sort(a, a+n);
    for (int i=0; i<n/2; i++)
    {
        c+=((a[i]+a[n-i-1])*(a[i]+a[n-i-1]));
    }
    сout << c;
}


/*.
░░░░░███████ ]▄▄▄▄▄▄ `~~~~~~ ~~~~ ~~~~ ~~~~~~
▂▄▅████Т-34████▅▄▃ ...............
Il███████████████████]
◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤..
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n, otvet=0;
    сin >> n;
    int *a=new int [n];
    for (int i=0; i<n; i++)
    {
        cin >> a[i];
    }
    sort(a, a+n);
    for (int i=0; i<n/2; i++)
    {
        otvet+=((a[i]+a[n-i-1])*(a[i]+a[n-i-1]));
    }
    сout << otvet;
}


/*.
░░░░░███████ ]▄▄▄▄▄▄ `~~~~~~ ~~~~ ~~~~ ~~~~~~
▂▄▅████Т-34████▅▄▃ ...............
Il███████████████████]
◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤..
*/
#inсlude <bits/stdс++.h>
using namespaсe std;
int main()
{
    long long int n, otvet=0;
    сin >> n;
    int *a=new int [n];
    for (int i=0; i<n; i++)
    {
        cin >> a[i];
    }
    sort(a, a+n);
    for (int i=0; i<n/2; i++)
    {
        otvet+=((a[i]+a[n-i-1])*(a[i]+a[n-i-1]));
    }
    сout << otvet;
}


/*.
░░░░░███████ ]▄▄▄▄▄▄ `~~~~~~ ~~~~ ~~~~ ~~~~~~
▂▄▅████Т-34████▅▄▃ ...............
Il███████████████████]
◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤..
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, c;
    cin >> n;
    int *a=new int [n];
    for (int i=0; i<n; i++)
    {
        cin >> a[i];
    }
    sort(a, a+n);
    for (int i=0; i<n/2; i++)
    {
        c=(a[i]+a[i-n-1])*(a[i]+a[i-n-1]);
    }
    cout << c;
}


/*.
░░░░░███████ ]▄▄▄▄▄▄ `~~~~~~ ~~~~ ~~~~ ~~~~~~
▂▄▅████Т-34████▅▄▃ ...............
Il███████████████████]
◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤..
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long int nx, c=0;
cin >> nx;
int *a=new int [nx];
for (int i=0; i<nx; i++)
{
cin >> a[i];
}
sort(a, a+nx);
for (int i=0; i<nx/2; i++)
{
c+=(a[i]+a[nx-i-1])*(a[i]+a[nx-i-1]);
}
cout << c;
}


#include<bits/stdc++.h>
#define r_0 return 0
#define pb push_back
#define ll long long
#define ld long double
#define l long
#define fr first
#define se second
#define Time ios_base::sync_with_stdio(0);
using namespace std;
int  n, m,x,y,t, ans = 1e9,res, sum, mx, mn = 1e9,z,cnt;
string s,s1,s3[4]= {"D","C","S","H"}, s2[13] = {"2","3","4","5","6","7","8","9","T","J","Q","K","A"};
set<int>st;
pair<int , int>pr;
vector<int>v,v1,v2,v3,v4;
map<int, int>mp , mpp;
char   b, c,d;
bool tr = false, fl = false;
ll used[10001];
int main()
{
         cin >> n;
         int a[n];
          for ( int i = 0; i < n; i ++ )
            cin >> a[i],v.pb(a[i]);
            sort( v.begin() ,v.end());
            for ( int i = 0; i < n / 2; i ++ )
             {
                     cnt += (v[i] + v[v.size()-i-1]) * (v[i] + v[v.size()-i-1]) ;
             }
            cout << cnt;
}


#include<bits/stdc++.h>
#define r_0 return 0
#define pb push_back
#define ll long long
#define ld long double
#define l long
#define fr first
#define se second
#define Time ios_base::sync_with_stdio(0);
using namespace std;
int  n, m,x,y,t, ans = 1e9,res, sum, mx, mn = 1e9,z,cnt;
string s,s1,s3[4]= {"D","C","S","H"}, s2[13] = {"2","3","4","5","6","7","8","9","T","J","Q","K","A"};
set<int>st;
pair<int , int>pr;
vector<int>v,v1,v2,v3,v4;
map<int, int>mp , mpp;
char   b, c,d;
bool tr = false, fl = false;
ll used[10001];
int main()
{
         cin >> n;
         int a[n];
          for ( int i = 0; i < n; i ++ )
            cin >> a[i],v.pb(a[i]);
            sort( v.begin() ,v.end());
            for ( int i = 0; i < n / 2; i ++ )
             {
                     cnt += (v[i] + v[(v.size()-1)-i]) * (v[i] + v[(v.size()-1)-i]) ;
             }
            cout << cnt;
}


#include<bits/stdc++.h>
#define r_0 return 0
#define pb push_back
#define ll long long
#define ld long double
#define l long
#define fr first
#define se second
#define Time ios_base::sync_with_stdio(0);
using namespace std;
int  n, m,x,y,t, ans = 1e9,res, sum, mx, mn = 1e9,z,cnt;
string s,s1,s3[4]= {"D","C","S","H"}, s2[13] = {"2","3","4","5","6","7","8","9","T","J","Q","K","A"};
set<int>st;
pair<int , int>pr;
vector<int>v,v1,v2,v3,v4;
map<int, int>mp , mpp;
char   b, c,d;
bool tr = false, fl = false;
ll used[10001];
int main()
{
         cin >> n;
          for ( int i = 0; i < n; i ++ )
            cin >> x,v.pb(x);
            sort( v.begin(), v.end() );
            for ( int i = 0; i < n / 2; i ++ )
             {
                 z ++;
                     cnt += (v[i] + v[v.size()-z]) * (v[i] + v[v.size()-z]) ;
             }
            cout << cnt;
}


#include<bits/stdc++.h>
#define r_0 return 0
#define pb push_back
#define ll long long
#define ld long double
#define l long
#define fr first
#define se second
#define Time ios_base::sync_with_stdio(0);
using namespace std;
int  n, m,x,y,t, ans = 1e9,res, sum, mx, mn = 1e9,z,cnt;
string s,s1,s3[4]= {"D","C","S","H"}, s2[13] = {"2","3","4","5","6","7","8","9","T","J","Q","K","A"};
set<int>st;
pair<int , int>pr;
vector<int>v,v1,v2,v3,v4;
map<int, int>mp , mpp;
char   b, c,d;
bool tr = false, fl = false;
ll used[10001];
int main()
{
         cin >> n;
         int a[n];
          for ( int i = 0; i < n; i ++ )
            cin >> a[i],v.pb(a[i]);
            sort( v.begin() , v.end() );
            for ( int i = 0; i < n / 2; i ++ )
             {
                 z ++;
                     cnt += (v[i] + v[v.size()-z]) * (v[i] + v[v.size()-z]) ;
             }
            cout << cnt;
}


#include<bits/stdc++.h>
#define r_0 return 0
#define pb push_back
#define ll long long
#define ld long double
#define l long
#define fr first
#define se second
#define Time ios_base::sync_with_stdio(0);
using namespace std;
int  n, m,x,y,t, ans = 1e9,res, sum, mx, mn = 1e9,z,cnt;
string s,s1,s3[4]= {"D","C","S","H"}, s2[13] = {"2","3","4","5","6","7","8","9","T","J","Q","K","A"};
set<int>st;
pair<int , int>pr;
vector<int>v,v1,v2,v3,v4;
map<int, int>mp , mpp;
char   b, c,d;
bool tr = false, fl = false;
ll used[10001];
int main()
{
         cin >> n;
         int a[n];
          for ( int i = 0; i < n; i ++ )
            cin >> a[i];
            sort( a, a + n );
            for ( int i = 0; i < n / 2; i ++ )
             {
                 z ++;
                     cnt += (a[i] + a[n-z]) * (a[i] + a[n-z]) ;
             }
            cout << cnt;
}


#include<bits/stdc++.h>
#define r_0 return 0
#define pb push_back
#define ll long long
#define ld long double
#define l long
#define fr first
#define se second
#define Time ios_base::sync_with_stdio(0);
using namespace std;
int  n, m,x,y,t, ans = 1e9,res, sum, mx, mn = 1e9,z,cnt;
string s,s1,s3[4]= {"D","C","S","H"}, s2[13] = {"2","3","4","5","6","7","8","9","T","J","Q","K","A"};
set<int>st;
pair<int , int>pr;
vector<int>v,v1,v2,v3,v4;
map<int, int>mp , mpp;
char   b, c,d;
bool tr = false, fl = false;
ll used[10001];
int main()
{
         cin >> n;
         int a[n];
          for ( int i = 0; i < n; i ++ )
            cin >> a[i];
            sort( a ,a + n );
            for ( int i = 0; i < n / 2; i ++ )
             {
                     cnt += (a[i] + a[n-i-1]) * (a[i] + a[n-i-1]) ;
             }
            cout << cnt;
}


#include<bits/stdc++.h>
#define r_0 return 0
#define pb push_back
#define ll long long
#define ld long double
#define l long
#define fr first
#define se second
#define Time ios_base::sync_with_stdio(0);
using namespace std;
ll n, m,x,y,t, ans = 1e9,res, sum, mx, mn = 1e9,z,cnt;
string s,s1,s3[4]= {"D","C","S","H"}, s2[13] = {"2","3","4","5","6","7","8","9","T","J","Q","K","A"};
set<int>st;
pair<int , int>pr;
vector<int>v,v1,v2,v3,v4;
map<int, int>mp , mpp;
char   b, c,d;
bool tr = false, fl = false;
ll used[10001];
int main()
{
         cin >> n;
         ll a[n];
          for ( int i = 0; i < n; i ++ )
            cin >> a[i],v.pb(a[i]);
            sort( v.begin() ,v.end());
            for ( int i = 0; i < n / 2; i ++ )
             {
                     cnt += (v[i] + v[(v.size()-1)-i]) * (v[i] + v[(v.size()-1)-i]) ;
             }
            cout << cnt;
}


#include<bits/stdc++.h>
using namespace std;

int n, num[400000], maxx, minn, ans, mim, mam;

void reedInp(int x) {
    for (int i = 0; i < n; i++)
        cin >> num[i];
}

int check(int x, int y) {
    if (maxx < x) {
        maxx = x;
        mam = y;
    }
    if (minn > x && x) {
        minn = x;
        mim = y;
    }
}

void cnt(int x[]) {
    maxx = 0, minn = 1001;
    for (int i = 0; i < n; i++)
        check(x[i], i);
    ans += (minn + maxx) * (minn + maxx);
    cout << minn << ' ' << maxx << endl;
    x[mam] = x[mim] = 0;
}

int main() {
    cin >> n;
    reedInp(n);
    for (int i = 0; i < n / 2; i++)
        cnt(num);
    cout << ans;
}


#include <bits/stdc++.h>
using namespace std;

const int N = 500000;
int num[N], n, sum;

void read() {
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> num[i], sum += num[i] * num[i];
}
int main () {
    read();
    sort(num, num + n);
    for (int i = 0; i < n / 2; i++)
        sum += (num[i] * num[n - i - 1]) * 2;
    cout << sum;
}


#include <bits/stdc++.h>
using namespace std;

const int N = 500000;
int num[N], n;
long long sum;

void read() {
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> num[i], sum += num[i] * num[i];
}
int main () {
    read();
    sort(num, num + n);
    for (int i = 0; i < n / 2; i++)
        sum += (num[i] * num[n - i - 1]) * 2;
    cout << sum;
}