#include <bits/stdc++.h>
using namespace std;
const long long N = 5005;
long long n, a[N], f[N][4];
pair<long long, long long> g[N][4];
long long c[4] = {1, -1, 1, -1};
void print(long long l, long long p) {
  if (l == 0) {
    for (long long i = 0; i < p; i++) printf("0 ");
    return;
  }
  pair<long long, long long> nxt = g[l][p];
  print(nxt.first, nxt.second);
  for (long long i = 1; i <= p - nxt.second - 1; i++)
    printf("%lld ", nxt.first);
  printf("%lld ", l);
}
signed main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) scanf("%lld", a + i);
  for (long long i = 0; i < 4; i++) g[0][i] = make_pair(0, i);
  for (long long i = 1; i <= n; i++) {
    f[i][0] = f[i - 1][0] + a[i];
    for (long long j = 1; j < 4; j++) {
      long long t = f[i - 1][j] + c[j] * a[i], l, p;
      for (long long k = 0; k < j; k++) {
        t = max(t, f[i - 1][k] + c[j] * a[i]);
      }
      for (long long k = 0; k < j; k++) {
        if (t == f[i - 1][k] + c[j] * a[i]) {
          l = i - 1, p = k;
        }
      }
      if (t == f[i - 1][j] + c[j] * a[i])
        l = g[i - 1][j].first, p = g[i - 1][j].second;
      f[i][j] = t, g[i][j] = make_pair(l, p);
    }
  }
  long long ans = -9e18, l, p;
  for (long long i = 0; i < 4; i++) {
    if (f[n][i] > ans) {
      ans = f[n][i], l = n, p = i;
    }
  }
  print(g[l][p].first, g[l][p].second);
  for (long long i = p + 1; i < 4; i++) printf("%lld ", n);
  return 0;
}
