#include <bits/stdc++.h>
using namespace std;
int n;
long long a[5005];
void input() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    a[i + 1] = a[i] + x;
  }
}
void solve() {
  long long outx, outy, outz, ans;
  ans = outx = outy = outz = 0;
  for (int i = 0; i <= n; i++) {
    long long z = a[i], lft = i;
    for (int j = i; j <= n; j++) {
      if (a[j] < z) {
        lft = j, z = a[j];
      }
      if (a[i] - a[lft] + a[j] > ans) {
        ans = a[i] - a[lft] + a[j];
        outx = i, outz = j, outy = lft;
      }
    }
  }
  printf("%lld %lld %lld", outx, outy, outz);
}
int main() {
  input();
  solve();
  return 0;
}
