#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e3 + 10;
const long long inf = (1 << 60) - 1;
long long a[maxn], sum[maxn], pre[maxn], suf[maxn];
int n, locp[maxn], locs[maxn];
int main() {
  while (cin >> n) {
    for (int i = 0; i <= n + 1; ++i) {
      pre[i] = suf[i] = -inf;
    }
    sum[0] = 0;
    for (int i = 1; i <= n; ++i) {
      scanf("%lld", &a[i]);
      sum[i] = sum[i - 1] + a[i];
    }
    for (int i = 0; i <= n; ++i)
      for (int j = 0; j <= i; ++j) {
        if (pre[i] < 2 * sum[j] - sum[i]) {
          pre[i] = 2 * sum[j] - sum[i];
          locp[i] = j;
        }
      }
    sum[n + 1] = 0;
    for (int i = n; i >= 1; --i) {
      sum[i] = sum[i + 1] + a[i];
    }
    for (int i = 1; i <= n + 1; ++i)
      for (int j = i; j <= n + 1; ++j) {
        if (suf[i] < sum[i] - 2 * sum[j]) {
          suf[i] = sum[i] - 2 * sum[j];
          locs[i] = j - 1;
        }
      }
    int mx = 0;
    for (int i = 0; i <= n; ++i) {
      if (pre[mx] + suf[mx + 1] < pre[i] + suf[i + 1]) mx = i;
    }
    printf("%d %d %d\n", locp[mx], mx, locs[mx + 1]);
  }
  return 0;
}
