#include <bits/stdc++.h>
using namespace std;
const int maxn = 5555;
long long sum[maxn], f[maxn][5];
int g[maxn][5];
void PRINT(int x, int op) {
  if (op == 1) return;
  PRINT(g[x][op], op - 1);
  printf("%d ", g[x][op]);
}
int main() {
  int N;
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) scanf("%I64d", sum + i), sum[i] += sum[i - 1];
  for (int i = 1; i <= N; ++i) f[i][1] = sum[i];
  for (int i = 1; i <= N; ++i)
    for (int j = 2; j <= 4; ++j) {
      int op;
      if (j & 1)
        op = 1;
      else
        op = -1;
      f[i][j] = f[i][j - 1];
      g[i][j] = i;
      for (int k = 0; k < i; ++k)
        if (f[k][j - 1] + op * (sum[i] - sum[k]) > f[i][j])
          f[i][j] = f[k][j - 1] + op * (sum[i] - sum[k]), g[i][j] = k;
    }
  PRINT(N, 4);
  return 0;
}
