#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
struct node{ll first, second, third;};
void solve(){
    ll n;
    cin >> n;
    ll values[n];
    ll who[n];
    fill(who, who+n, -1);
    ll sum = 0;
    for(ll i = 0; i<n; i++){ cin >> values[i]; sum+=values[i];}
    sum/=3;
    ll pos = 0;
    ll current = 0;
    for(ll i = 0; i<n; i++){
        pos=i;
        current+=values[i];
        if(current>=sum) break;
    }
    ll so = pos;
    pos=0;
    for(ll i = so; i<n; i++){
        if(i!=so) current+=values[i];
        while(pos<i && current-values[pos]>=sum){
            current-=values[pos];
            pos++;
        }
        if(current==sum) who[i]=pos;
    }
    node ans;
    for(ll i = 0; i<n; i++){
        if(who[i]==-1) continue;
        ll prev = who[i];
        if(prev==0) prev=n-1;
        else prev--;
        if(who[prev]!=-1){
            //cout << i << ' ' << prev << '\n';
            ans.first = who[i];
            ans.second = who[prev];
            ans.third = i+1;
            //cout << "really" << ans.third << '\n';
            break;
        }
    }
    //cout << ans.first << ' ' << ans.second << ' ' << ans.third << '\n';
    ans.first%=n;
    ans.second%=n;
    ans.third%=n;
    ans.first++;
    ans.second++;
    ans.third++;
    if(ans.first>ans.second) swap(ans.first, ans.second);
    if(ans.second>ans.third) swap(ans.second, ans.third);
    if(ans.first>ans.second) swap(ans.first, ans.second);
    cout << "0" << '\n';
    cout << ans.first << ' ' << ans.second << ' ' << ans.third << '\n';
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    freopen("input.txt", "r", stdin);
    ll tests;
    tests=1;
    while(tests--) solve();
}