#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
const ll SIZ = ((ll)7e5 + 5), LONGBOI = ((ll)1e17 + 5);
mt19937_64 REALrandom(chrono::system_clock::to_time_t(chrono::system_clock::now()));

ll n, need, l, r, sum, s1, s2, s3;
ll a[SIZ],p[SIZ];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("output.txt", "w", stdout);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        p[i]=p[i-1]+a[i];
    }

    need = p[n] / 3;
    l = 1; r = 1; sum = a[1];
    while(true){
        if(sum == need){
            s1 = l;
            s2 = r+1;
            break;
        }
        else if(sum < need){
            r++;
            if(r > n) r-= n;
            sum += a[r];
        }
        else if(sum > need){
            l++;
            if(l > n) l-= n;
            sum -= a[l];
        }
    }
    l = s2; r = s2; sum = a[l];
    while(true){
        if(sum == need){
            s3 = r+1;
            break;
        }
        else if(sum < need){
            r++;
            if(r > n) r-= n;
            sum += a[r];
        }
        else if(sum > need){
            l++;
            if(l > n) l-= n;
            sum -= a[l];
        }
    }

    ll ans[3]; ans[0] = s1; ans[1] = s2; ans[2] = s3;
    sort(ans, ans+3);

    cout << 0 << endl;
    for(int i=0; i < 3; i++) cout << ans[i] << " ";
    cout << endl;

    return 0;
}
