#include <bits/stdc++.h>
using namespace std;
int a[5050];
int pr1[5050];
long long t1[5050];
long long p[5050];
int a1 = 0, a2 = 0, a3 = 0;
long long ans = -1e18;
long long summ(int l, int r) { return p[r] - p[l]; }
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    p[i + 1] = p[i] + a[i];
  }
  for (int i = 0; i <= n; i++) {
    long long tsum = -1e18;
    for (int j = i; j >= 0; j--) {
      if (summ(0, j) - summ(j, i) > tsum) {
        pr1[i] = j;
        tsum = summ(0, j) - summ(j, i);
        t1[i] = tsum;
      }
    }
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= i; j++) {
      long long tans = t1[j] + summ(j, i) - summ(i, n);
      if (tans > ans) {
        ans = tans;
        a1 = pr1[j];
        a2 = j;
        a3 = i;
      }
    }
  }
  cout << a1 << " " << a2 << " " << a3;
  return 0;
}
