#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, s = 0;
    cin>>n;
    long long a[n + 5];
    a[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        a[i] += a[i - 1];
    }
    s = a[n] / 3;
    for (int x = 1; x < n; x++)
    {
        int l = x + 1, r = n, mid;
        while (l < r)
        {
            mid = (l + r) / 2;
            if (a[mid - 1] - a[x - 1] < s) l = mid + 1;
            else r = mid;
        }
        if (a[l - 1] - a[x - 1] != s) continue;
        int y = l;
        if (y == n) continue;
        l = y + 1;
        r = n;
        while (l < r)
        {
            mid = (l + r) / 2;
            if (a[mid - 1] - a[y - 1] < s) l = mid + 1;
            else r = mid;
        }
        if (a[l - 1] - a[y - 1] != s) continue;
        if (x < y && y < l) return cout << "0\n" << x << " " << y << " " << l << "\n", 0;
    }
}

