#include using namespace std; #define int long long // aaaaaaaaaaaaaaaaaa #define rep(i,a,n) for (int i=a;i=a;i--) #define pb push_back #define mp make_pair #define all(x) (x).begin(),(x).end() #define allr(x) (x).rbegin(),(x).rend() #define in(s,x) s.find(x) != s.end() #define fi first #define se second #define SZ(x) ((int)(x).size()) #define SIZE(buff) (sizeof(buff)/sizeof(buff[0])) typedef vector VI; typedef vector > VVI; typedef long long ll; typedef pair PII; typedef vector> VPII; const ll mod=1000000007; const ll INF= 1LL<<60-1; ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;} ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;} template void chmin(T& a,const T& b) { if(a>b) a=b; } template void chmax(T& a,const T& b) { if(aostream &operator<<(ostream &o,const vector&v) {o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<ostream& operator << (ostream& os, pair& pair_var) {os << "(" << pair_var.first << ", " << pair_var.second << ")";return os;} // head int m,n,k,res,tmp,tmp2,tmp3,h,w,x,y; VI a; deque que; string s; //VI b; vector g[2100600]; int b[2100000]; int c[210000] = {}; int rui[210000]; set ch; #define N 100008 class BIT { int n; ll data[N]; public: BIT(int n) : n(n) { for(int i = 0; i < n+2; ++i) data[i] = 0; } void add(int k, ll x) { while(k <= n) { data[k] += x; k += k & -k; } } ll get(int k) { ll s = 0; while(k) { s += data[k]; k -= k & -k; } return s; } }; signed main() { cin.tie(0); ios::sync_with_stdio(false); cin>>n; rep(i,0,n){ cin>>b[i]; // b[i] += 1LL<<30; ch.insert(b[i]); } sort(b,b+n); if(ch.size()==1){cout << 1 << '\n'; exit(0);} BIT bit(n+1); rep(i,0,n){ bit.add(i+1,b[i]); } int ans = INF; rep(i,0,n){ x = i/2; tmp = bit.get(i/2+1); tmp2 = bit.get(i+1); int mae = b[x]*(x+1)-tmp+(tmp2-tmp)-b[x]*(i-x); y = (n+i)/2; tmp3 = bit.get(y+1); int tmp4 = bit.get(n); int usi = b[y]*(y-i)-(tmp3-tmp2) +(tmp4-tmp3)-b[y]*(n-y-1); // cout << mae <<" "<