#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n;
vector<ll> v;
ll res;
vector<ll>res2;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >>n;
    v.resize(n);
    ll s = 0;
    for(int i=0;i<n;i++)
    {
        cin >>v[i];
        //v.push_back(v[i]);
        s+=v[i];
    }
    ll a,b,c;
    if (s%3==0)
    {
        res = 0;
        a = s/3;
        b = s/3;
        c = s/3;
    }
    else if (s%3==1)
    {
        res = 1;
        a = s/3;
        b = s/3;
        c = s/3+1;
    }
    else
    {
        res = 1;
        a = s/3;
        b = s/3+1;
        c = s/3+1;
    }
    c = -1;
    ll cur = 0;
    res2.push_back(1);
    for (int i=0;i<n;i++)
    {
        if (a==-1) break;
        cur += v[i];
        if (cur==a)
        {
            res2.push_back(i+2);
            cur = 0;
            a = b;
            b = c;
        }
    }
    cout <<res<<endl;
    cout <<res2[0]<<" "<<res2[1]<<" "<<res2[2];
    
}
