#include <bits/stdc++.h>
using namespace std;
const int MAX = 5100;
const long long oo = 1ll << 60;
long long N, A[MAX], cum[MAX], sum, pref, sol = -oo, curr, lowest = oo, lo, mi,
                                          tlo, tmi, hi;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N;
  for (int I = 0; I < N; I++) {
    cin >> A[I];
    cum[I + 1] = cum[I] + A[I];
    sum += A[I];
  }
  for (int r = 0; r <= N; r++) {
    curr = -(sum - pref);
    curr += pref;
    for (int I = 0; I <= r; I++)
      if (lowest > cum[r] - cum[I]) {
        lowest = cum[r] - cum[I];
        tlo = I;
        tmi = r;
      }
    curr -= 2 * lowest;
    if (sol < curr) {
      lo = tlo;
      mi = tmi;
      hi = r;
      sol = curr;
    }
    pref += A[r];
  }
  cout << lo << " " << mi << " " << hi << endl;
}
