#include <bits/stdc++.h>
using namespace std;
const int maxn = 5005;
int n, lim1, lim0, lim2;
int a[maxn];
long long sum[maxn];
long long ans = -1LL * 1e9 * 1e9;
long long Sum(int l, int r) { return sum[r - 1] - (l == 0 ? 0 : sum[l - 1]); }
int main() {
  scanf("%d", &n);
  for (int(i) = 0; (i) < n; i++) scanf("%d", &a[i]);
  sum[0] = a[0];
  for (int(i) = 1; (i) <= n - 1; i++) sum[i] = sum[i - 1] + a[i];
  for (int(i) = 0; (i) < n + 1; i++) {
    long long cur = -1LL * 1e9 * 1e9, mx = -1LL * 1e9 * 1e9;
    int cur1, cur2;
    for (int(j) = 0; (j) < i + 1; j++) {
      long long now = Sum(0, j) - Sum(j, i);
      if (now > mx) {
        mx = now;
        cur1 = j;
      }
    }
    cur = mx;
    mx = -1LL * 1e9 * 1e9;
    for (int j = i; j <= n; j++) {
      long long now = Sum(i, j) - Sum(j, n);
      if (now > mx) {
        mx = now;
        cur2 = j;
      }
    }
    cur += mx;
    if (cur > ans) {
      lim0 = cur1;
      lim1 = i;
      lim2 = cur2;
      ans = cur;
    }
  }
  printf("%d %d %d", lim0, lim1, lim2);
  return 0;
}
