#pragma GCC optimize("Ofast,unroll-loops") #include using namespace std; using Int = long long; typedef pair Pi; typedef pair Pl; constexpr int mod = 1e9+7; constexpr int INF32 = numeric_limits::max(); constexpr Int INF64 = numeric_limits::max(); #define END {cout< #define gPr(t) priority_queue,greater> #define V(t) vector #define rer(i,l,r) for(int(i)=(l); (i)<(r); ++(i)) #define rep(i,n) rer(i,0,n) #define gnr(i,l,r) for(int (i)=(r)-1; (i)>=(l); --(i)) #define eb emplace_back #define pri(a) cout<<(a)<<'\n' #define pri2(a,n) {rep(i,n-1)cout< inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } int n,m,_,x,y,q; string s,sb; bool ok; char cf,cb; int main(){ cin.tie(nullptr); ios::sync_with_stdio(0); //cout<>n>>m; int a[n]; rep(i,n)cin>>a[i]; double ans = 0; rep(i,pow(m,n)){ V(int) v[m]; x=i; rep(j,n){ v[x%m].eb(a[j]); x/=m; } double ave[m]={}; rep(j,m){ for(auto e:v[j])ave[j]+=e; ave[j]/=v[j].size(); } cmax(ans, *max_element(ave, ave+m)-*min_element(ave, ave+m)); } pri(floor(ans+0.5)); }