#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define all(a) (a).begin(), (a).end()

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

    int n;
    cin >> n;
    vector<int> a(n);
    map<ll, ll> occ;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (i != 0) a[i]+=a[i - 1];
        occ[a[i]] = i;
    }
    if (a[n - 1] == 0) {
        cout << "0\n1 2 3\n" << '\n';
        return 0;
    }
    ll ci = 0, cj = 0, ck = 0;
    for (int i = 0; i < n; i++) {
        if (!occ.count((i == 0 ? 0 : a[i - 1]) + a[n - 1]/3)) continue;
        int j = occ[(i == 0 ? 0 : a[i - 1]) + a[n - 1]/3] + 1;
        if (!occ.count((j == 0 ? 0 : a[j - 1]) + a[n - 1]/3)) continue;
        int k = occ[(j == 0 ? 0 : a[j - 1]) + a[n - 1]/3] + 1;
        ci = i, cj = j, ck = k;
    }
    cout << 0 << '\n' << ci + 1 << ' ' << cj + 1 << ' ' << ck + 1 << endl;
}