#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define vll vector<ll>
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define fr first
#define se second
#define pb push_back
#define vvll vector<vll>
#define pll pair<ll, ll>
#define vbool vector<bool>

using namespace std;
using namespace __gnu_pbds;

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

    ll n;
    cin >> n;
    vll a(n), pref(n+7, 0);
    ll s = 0;
    for (int i = 0; i < n; i ++) {
        cin >> a[i];
        pref[i+1] = pref[i];
        pref[i+1] += a[i];
        s += a[i];
    }
    s /= 3;
    ll x, y, z;

    for (int i = 0; i < n; i ++) {
        ll l = i, r = n;
        while (r-l > 1) {
            ll x = (l+r)/2;
            if (pref[x+1]-pref[i] <= s) l = x;
            else r = x;
        }
        if (pref[l+1]-pref[i] == s) {
            x = i, y = l+1;
            l ++, r = n;
            while (r-l > 1) {
                ll x = (l+r)/2;
                if (pref[x+1]-pref[y] <= s) l = x;
                else r = x;
            }
            if (pref[l+1]-pref[y] == s) {
                cout << 0 << endl;
                if (l == n-1) {
                    l = 0;
                    cout << l+1 << ' ' << x+1 << ' ' << y+1 << endl;
                }
                else cout << x+1 << ' ' << y+1 << ' ' << l+2 << endl;
                return 0;
            }
        }
    }


}