#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 1000005;
long long f[5010][5];
int _prev[5010][5], n;
int a[MAXN];
long long sum[MAXN];
int main() {
  scanf("%d", &n);
  for (int i = (1); i < (n + 1); i++) scanf("%d", a + i);
  for (int i = (1); i < (n + 1); i++) sum[i] = sum[i - 1] + a[i];
  for (int i = (1); i < (n + 1); i++)
    for (int j = (0); j < (4); j++) {
      if (j == 0)
        f[i][j] = sum[i];
      else {
        f[i][j] = 1ll << 63;
        for (int k = (0); k < (i + 1); k++) {
          if (j & 1 && f[i][j] < f[k][j - 1] - sum[i] + sum[k])
            _prev[i][j] = k, f[i][j] = f[k][j - 1] - sum[i] + sum[k];
          if (!(j & 1) && f[i][j] < f[k][j - 1] + sum[i] - sum[k])
            _prev[i][j] = k, f[i][j] = f[k][j - 1] + sum[i] - sum[k];
        }
      }
    }
  long long ans = 1ll << 63, t;
  stack<int> res;
  for (int k = (0); k < (4); k++)
    if (ans <= f[n][k]) ans = f[n][k], t = k;
  int now = n;
  while (t) {
    now = _prev[now][t];
    res.push(now);
    t--;
  }
  for (int i = (0); i < (3); i++) {
    if (res.empty())
      printf("%d ", n);
    else
      printf("%d ", res.top()), res.pop();
  }
  return 0;
}
