#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-7;
const int MOD = 1e9 + 7;
const long long INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e4 + 5;
long long d[MAXN][4], pre[MAXN];
int par[MAXN][4], a[MAXN];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) pre[i] = a[i] + pre[i - 1];
  for (int i = 0; i <= n; i++) {
    d[i][0] = pre[i];
    for (int j = 0; j <= i; j++) {
      for (int k = 1; k <= 3; k++) {
        long long w = d[j][k - 1] + (k & 1 ? -1 : 1) * (pre[i] - pre[j]);
        if (w > d[i][k]) {
          d[i][k] = w;
          par[i][k] = j;
        }
      }
    }
  }
  printf("%d %d %d\n", par[par[par[n][3]][2]][1], par[par[n][3]][2], par[n][3]);
}
