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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    vector<unsigned> arr(n);
    vector<unsigned long long> pref(n+1,0);
    vector<unsigned> res;

    for(int i = 0; i <n; i++){
        unsigned num;
        cin>>num;
        arr[i] = num;
        pref[i+1] = num+pref[i];
    }

    int m = pref[n]/3;
    int r = 1,l = 0;
    for(int i = 0; i<2;i++){
        while(pref[r]-pref[l] < m && r != n-2+i){
            r++;
        }
        int res1 = -1*(pref[r-1]- pref[l] - m);
        int l1 = l;

        while(pref[r]-pref[l] >= m){
            l++;
        }

        int res2 = -1*(pref[r]-pref[l] - m);
        int res3 = pref[r]-pref[l-1] - m;
        if(res3<0) res3 *= -1;

        if(res3 < res2){
            res2 = res3;
            l--;
        }
        
        if(res1 < res2){
            res.push_back(l1+1);
        }else{
            res.push_back(l+1);
        }
        l = r;
        r +=1;
    }
    res.push_back(r);

    for(int i = 0; i<3;i++){
        cout<<res[i]<<" ";
    }
}
