#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define ff first
#define ss second
#define pb push_back

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

    int n;
    cin >> n;
    vector<ll> v(n+1), pref(n+1);
    for (int i=1; i<=n; i++)
        cin >> v[i];
    pref[0] = 0;
    for (int i=1; i<=n; i++) {
        pref[i] = pref[i-1] + v[i];
    }
    cout << 0 << "\n";
    ll x = pref[n]/3, s=0, t=1;
    bool f = true;
    for (int i=1; i<n; i++) {
        s += v[i];
        while (s > x) {
            s -= v[t];
            t++;
        }
        if (s == x) {
            if (f) {
                cout << t << " " << i+1 << " ";
                f = false;
            }else {
                cout << i+1;
                return 0;
            }
            t = i+1;
            s = 0;
        }
    }

}