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

#define   fi(a,b) for(int i=a;i<b;i++)
#define   fj(a,b) for(int j=a;j<b;j++)
#define   ff first
#define   ss second
#define   ll long long
#define   ld long double
#define   ull unsigned long long
#define   bp(x) __builtin_popcount(x)
#define   pr(x) for(auto it: x) cout<<it<<" "; cout<<endl;
#define   getMax(x) max_element(x.begin(),x.end())
#define   getMin(x) min_element(x.begin(),x.end())
#define   endl "\n"
typedef   vector<int> vi;
typedef   vector< pair<int,int> > vii;
typedef   vector<long long> vl;
typedef   pair<int,int> pii;
typedef   pair<ll,ll> pll;
typedef   vector< pair<ll,ll> > vll;
//int dx[]={1,0,-1,0};
//int dy[]={0,1,0,-1};
//int dx[]={-1,0,1,1,1,0,-1,-1};
//int dy[]={-1,-1,-1,0,1,1,1,0};

void nikal_pehli_fursat_mai(){
    ll n;
    cin>>n;
    vl v(n);
    vl h(401, 0);
    fi(0, n) {
        cin>>v[i];
    }
    ll ans = 0;
    h[v[0]+200]++;
    fi(1, n){
        fj(0, 401){
            ans += abs(v[i]-(j-200))*abs(v[i]-(j-200))*h[j];
        }
        h[v[i]+200]++;
    }
    cout<<ans<<endl;
}

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int tc=1; 
    // cin>>tc;
    while(tc--){
    nikal_pehli_fursat_mai();
    }
}

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n; ll k; cin >> n >> k;
    ll dp[4][3000005] = {0};
    dp[0][0] = 1;
    for(int i = 0; i < 3;i++){
        for(int j = 0; j <= i * n;j++){
            dp[i + 1][j + 1]     += dp[i][j];
            dp[i + 1][j + n + 1] -= dp[i][j];
        }

        for(int j = 1; j <= (i + 1) * n; j++){
            dp[i + 1][j] += dp[i + 1][j - 1];
        }
    }

    int x;
    for(int i = 3; i <= 3 * n; i++){
        if(k <= dp[3][i]){
            x = i; break;
        }else{
            k -= dp[3][i];
        }
    }

    for(int i = 1; i <= n; i++){
        int j_mi = max(1, x - i - n);
        int j_ma = min(n, x - i - 1);

        if(j_mi > j_ma) continue;
        if(k > (j_ma - j_mi + 1)){
            k -= (j_ma - j_mi + 1);
            continue;
        }

        int y = j_mi + k - 1;
        int z = x - i - y;
        cout << i << " " << y << " " << z << endl;
        return 0;
    }
}


