#include <bits/stdc++.h>
using namespace std;
int N;
double numbers[5001];
double sums[5001];
int guide[5][5001];
double dp[5][5001];
int maximum_index = 0;
double get_sum(int i, int j) {
  return (i == 0) ? sums[j - 1] : sums[j - 1] - sums[i - 1];
}
double get_maximum(int count, int idxA) {
  double maximum = 0;
  double &rnt = dp[count][idxA];
  if (rnt != -1) return rnt;
  if (count == 3) return rnt = -1 * get_sum(idxA, N);
  for (int i = idxA; i <= N; i++) {
    if (count % 2 == 0) {
      maximum = get_sum(idxA, i) + get_maximum(count + 1, i);
      if (rnt < maximum) {
        rnt = maximum;
        guide[count][idxA] = i;
      }
    } else {
      maximum = -1 * get_sum(idxA, i) + get_maximum(count + 1, i);
      if (rnt < maximum) {
        rnt = maximum;
        guide[count][idxA] = i;
      }
    }
  }
  return rnt;
}
int main() {
  int tmp = -2;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%lf", &numbers[i]);
  }
  sums[0] = numbers[0];
  for (int i = 1; i < N; i++) {
    sums[i] = sums[i - 1] + numbers[i];
  }
  for (int i = 0; i <= 4; i++) {
    for (int j = 0; j <= N; j++) {
      dp[i][j] = -1;
    }
  }
  memset(guide, 0, sizeof(guide));
  get_maximum(0, 0);
  for (int i = 0; i <= 2; i++) {
    if (tmp == -2) {
      cout << guide[0][0] << " ";
      tmp = guide[0][0];
    } else {
      cout << guide[i][tmp] << " ";
      tmp = guide[i][tmp];
    }
  }
  cout << endl;
}
