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

#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define all(x) x.begin(), x.end()
#define fastread ios_base::sync_with_stdio(0);cin.tie(NULL)
#define sum(x) accumulate(all(x),0LL)
#define what_is(x) cerr << #x << " = " << (x) << '\n'
#define pb push_back

int main()
{
    fastread;

    int n;
    cin >> n;
    ll v[10005] = {0},pref[10005] = {0},s = 0;
    for(int i = 1; i <= n; i++) {
        cin >> v[i];
        pref[i] = pref[i-1] + v[i];
        s += v[i];
    }
    int ind1 = 0,ind2 = 0;
    while (pref[ind2] - pref[ind1 - 1] != s / 3) {
        if (pref[ind2] - pref[ind1 - 1] < s / 3) {
            ind2++;
        }
        else {
            ind1++;
        }
    }
    ind2++;
    int ind3 = 0;
    if (s % 3 == 0) {
        while (pref[ind3] - pref[ind2 - 1] != s / 3) {
            if ((pref[n] - pref[ind3 - 1]) + pref[ind1] < s / 3) {
                if (ind3 + 1 <= n)
                    ind3++;
                else {
                    ind2--;
                    ind1--;
                }
            }
        }
    }
    cout << ind1 << " " << ind2 << " " << ind3;

    return 0;
}

