#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];
    }

    cout << "0\n";

    sum /= 3;
    long long sum_l, l, r = 0;
    for (int i = 0; i < 2; i++) {
        sum_l = v[r];
        l = r;
        r++;
        while (sum_l != sum) {
            if (sum_l < sum) {
                sum_l += v[r];
                r++;
            } else {
                sum_l -= v[l];
                l++;
            }
        }
        cout << l + 1 << " ";
    }
    cout << r + 1;
}
