#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;
    int a[n];
    int tsm = 0;
    for(int i = 0;i<n;i++){
        cin>>a[i];
        tsm += a[i];
    }
    if(tsm == 0){
        cout<<0<<endl<<1<<' '<<2<<' '<<3;
    }
    else{
        map<int,int>mp;
        mp[0] = 1;
        int sm = 0;
        cout<<0<<endl;
        for(int i = 0;i<n;i++){
            //cout<<i<<' '<<sm<<endl;
            sm += a[i];
            mp[sm] = i+2;
            if(sm >= (tsm/3)*2){
                if(mp[sm-tsm/3] && mp[sm-tsm/3-tsm/3]){
                    cout<<mp[sm-tsm/3-tsm/3]<<' '<<mp[sm-tsm/3]<<' '<<i+2;
                    break;
                }
            }
        }
    }
}
