#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\n0 ";
        long long sum_l = 0, x = 0;
        while (sum_l < sum) {
            sum_l += v[x];
            x++;
        }
        cout << x << " ";
        sum_l = 0;
        while (sum_l < sum) {
            sum_l += v[x];
            x++;
        }
        cout << x << " ";
    } else if (res == 1) {
        cout << "1\n0 ";
        long long sum_l = 0, x = 0;
        while (sum_l < sum + 1) {
            sum_l += v[x];
            x++;
        }
        cout << x << " ";
        sum_l = 0;
        while (sum_l < sum) {
            sum_l += v[x];
            x++;
        }
        cout << x << " ";
    } else if (res == 2) {
        cout << "1\n0 ";
        long long sum_l = 0, x = 0;
        while (sum_l < sum + 1) {
            sum_l += v[x];
            x++;
        }
        cout << x << " ";
        sum_l = 0;
        while (sum_l < sum + 1) {
            sum_l += v[x];
            x++;
        }
        cout << x << " ";
    }
}
