Language: C++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

#ifdef I64d_OJ
#define LL __int64
#endif // I64d_OJ
//#ifdef I64d_OJ
//#define LL long long
//#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline LL read(){
    LL x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-10;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 1e6+10;
const int MAXM = (int) 1e6+10;
const int sigma_size = (int) 26;

///--------------------START-------------------------
int N;
int a[MAXN];
int b[MAXN];

void work(){
    scanf("%d",&N);
    for(int i=0;i<N;i++) scanf("%d",&a[i]);
    sort(a,a+N);
    LL ans=0,big=0,small=0;
    if(N%2==1){
        for(int i=0;i<(N+1)/2;i++) small+=a[i];
        for(int i=(N+1)/2;i<N;i++) big+=a[i];
        ans=big*2-small*2+a[(N+1)/2-2]+a[(N+1)/2-1];
        small=big=0;
        for(int i=0;i<N/2;i++) small+=a[i];
        for(int i=N/2;i<N;i++) big+=a[i];
        ans=max(ans,big*2-small*2-a[N/2]-a[N/2+1]);
        printf("%lld\n",ans);
    }
    else{
        for(int i=0;i<N/2;i++) small+=a[i];
        for(int i=N/2;i<N;i++) big+=a[i];
        printf("%lld\n",big*2-small*2-a[N/2]+a[N/2-1]);
    }
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}

















Compiler output:
a.cc:29:21: error: expected initializer before 'ULL'
   29 | typedef unsigned LL ULL;
      |                     ^~~
a.cc:23:12: error: '__int64' was not declared in this scope; did you mean '__ynf64'?
   23 | #define LL __int64
      |            ^~~~~~~
a.cc:33:14: note: in expansion of macro 'LL'
   33 | typedef pair<LL,LL> pLL;
      |              ^~
a.cc:23:12: error: '__int64' was not declared in this scope; did you mean '__ynf64'?
   23 | #define LL __int64
      |            ^~~~~~~
a.cc:33:17: note: in expansion of macro 'LL'
   33 | typedef pair<LL,LL> pLL;
      |                 ^~
a.cc:33:19: error: template argument 1 is invalid
   33 | typedef pair<LL,LL> pLL;
      |                   ^
a.cc:33:19: error: template argument 2 is invalid
a.cc:23:12: error: '__int64' does not name a type; did you mean '__int64_t'?
   23 | #define LL __int64
      |            ^~~~~~~
a.cc:36:8: note: in expansion of macro 'LL'
   36 | inline LL read(){
      |        ^~
a.cc: In function 'void work()':
a.cc:23:12: error: '__int64' was not declared in this scope; did you mean '__ynf64'?
   23 | #define LL __int64
      |            ^~~~~~~
a.cc:76:5: note: in expansion of macro 'LL'
   76 |     LL ans=0,big=0,small=0;
      |     ^~
a.cc:78:36: error: 'small' was not declared in this scope; did you mean 'scalbl'?
   78 |         for(int i=0;i<(N+1)/2;i++) small+=a[i];
      |                                    ^~~~~
      |                                    scalbl
a.cc:79:36: error: 'big' was not declared in this scope
   79 |         for(int i=(N+1)/2;i<N;i++) big+=a[i];
      |                                    ^~~
a.cc:80:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   80 |         ans=big*2-small*2+a[(N+1)/2-2]+a[(N+1)/2-1];
      |         ^~~
      |         abs
a.cc:80:13: error: 'big' was not declared in this scope
   80 |         ans=big*2-small*2+a[(N+1)/2-2]+a[(N+1)/2-1];
      |             ^~~
a.cc:80:19: error: 'small' was not declared in this scope; did you mean 'scalbl'?
   80 |         ans=big*2-small*2+a[(N+1)/2-2]+a[(N+1)/2-1];
      |                   ^~~~~
      |                   scalbl
a.cc:88:32: error: 'small' was not declared in this scope; did you mean 'scalbl'?
   88 |         for(int i=0;i<N/2;i++) small+=a[i];
      |                                ^~~~~
      |                                scalbl
a.cc:89:32: error: 'big' was not declared in this scope
   89 |         for(int i=N/2;i<N;i++) big+=a[i];
      |                                ^~~
a.cc:90:25: error: 'big' was not declared in this scope
   90 |         printf("%lld\n",big*2-small*2-a[N/2]+a[N/2-1]);
      |                         ^~~
a.cc:90:31: error: 'small' was not declared in this scope; did you mean 'scalbl'?
   90 |         printf("%lld\n",big*2-small*2-a[N/2]+a[N/2-1]);
      |                               ^~~~~
      |                               scalbl