#include <bits/stdc++.h>
using namespace std;

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

    long long n;
    cin >> n;
    long long v[n], sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        sum += v[i];
    }

    int res = sum % 3;
    sum /= 3;
    if (res == 0) {
        cout << "0\n";
        long long sum_l = v[0], x = 0;
        while (sum_l < sum) {
            x++;
            sum_l += v[x];
        }
        cout << x + 1 << " ";
        x++;
        sum_l = v[x];
        while (sum_l < sum + 0) {
            x++;
            sum_l += v[x];
        }
        cout << x + 1 << " ";
        x++;
        sum_l = v[x];
        while (sum_l < sum + 0) {
            x++;
            sum_l += v[x];
        }
        cout << x + 1;
    } else if (res == 1) {
        cout << "1\n";
        long long sum_l = v[0], x = 0;
        while (sum_l < sum + 1) {
            x++;
            sum_l += v[x];
        }
        cout << x + 1 << " ";
        x++;
        sum_l = v[x];
        while (sum_l < sum + 0) {
            x++;
            sum_l += v[x];
        }
        cout << x + 1 << " ";
        x++;
        sum_l = v[x];
        while (sum_l < sum + 0) {
            x++;
            sum_l += v[x];
        }
        cout << x + 1;
    } else if (res == 2) {
        cout << "1\n";
        long long sum_l = v[0], x = 0;
        while (sum_l < sum + 1) {
            x++;
            sum_l += v[x];
        }
        cout << x + 1 << " ";
        x++;
        sum_l = v[x];
        while (sum_l < sum + 0) {
            x++;
            sum_l += v[x];
        }
        cout << x + 1<< " " << x + 2;
    }
}
