#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;
    long long a[n],pref[n+1];
    pref[0]=0;
    for(long long i=0; i<n; i++){
        cin>>a[i];
        pref[i+1]=pref[i]+a[i];
    }
    long long s=pref[n]/3,curr=0,cnt=0;
    cout<<pref[n]%3<<endl;
    if(s==0){
        cout<<"1 2 3";
    }
    cout<<1<<' ';
    for(long long i=0; i<n; i++){
        if(curr==s && cnt<2){
            curr=0;
            cout<<i+1<<' ';
            cnt++;
        }
        curr+=a[i];
    }
}
