#include <bits/stdc++.h>
using namespace std;
const int N = 5009;
long long a[N];
long long sum[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%I64d", a + i);
  partial_sum(a, a + n, sum + 1);
  long long ans = sum[n];
  sum[n + 1] = sum[n];
  int a = n, b = n, c = n;
  for (int i = 1; i <= n; i++) {
    long long lef = -1e15;
    int lefidx = 0;
    for (int l = 1; l <= i; l++) {
      long long cur = sum[l - 1];
      cur -= sum[i - 1] - sum[l - 1];
      if (cur > lef) lefidx = l - 1;
      lef = max(lef, cur);
    }
    long long rit = -1e15;
    int ritidx = 0;
    for (int r = i; r <= n + 1; r++) {
      long long cur = sum[r - 1] - sum[i - 1];
      cur -= sum[n] - sum[r - 1];
      if (cur > rit) ritidx = r - 1;
      rit = max(rit, cur);
    }
    if (lef + rit > ans) a = lefidx, b = i - 1, c = ritidx, ans = lef + rit;
  }
  printf("%d %d %d\n", a, b, c);
}
