#include using namespace std; #define modulo 1000000007 #define mod(mod_x) ((((long long)mod_x+modulo))%modulo) #define Inf 10000000.0 long long get_score(vector &a,int m){ if(m>=a.size()||m<0)return 0; long long ret = 0; long long S = 0; for(int i=m-1;i>=0;i--){ S += a[i]; S += a[a.size()-1 - (m-1-i)]; S -= 2*a[m]; ret = max(ret,S); } return ret; } int main(){ int N; cin>>N; vector a(N); for(int i=0;i>a[i]; } sort(a.begin(),a.end()); long long ans = -1; int ind; for(int i=0;ians){ ans = s; ind = i; } } for(int i=ind-500;i<=ind+500;i++){ ans = max(ans,get_score(a,i)); } cout<