#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 5000;
int n;
int a[MAXN];
long long sum[MAXN + 1];
long long dp[4][MAXN + 1];
int act[4][MAXN + 1];
void run() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) scanf("%d", &a[i]);
  sum[0] = 0;
  for (int i = (0); i < (n); ++i) sum[i + 1] = sum[i] + a[i];
  for (int i = (0); i <= (n); ++i)
    dp[3][i] = -(sum[n] - sum[i]), act[3][i] = -1;
  for (int i = (0); i <= (n); ++i) {
    dp[2][i] = LLONG_MIN, act[2][i] = -1;
    for (int j = (i); j <= (n); ++j) {
      long long cur = +(sum[j] - sum[i]) + dp[3][j];
      if (cur > dp[2][i]) dp[2][i] = cur, act[2][i] = j;
    }
  }
  for (int i = (0); i <= (n); ++i) {
    dp[1][i] = LLONG_MIN, act[1][i] = -1;
    for (int j = (i); j <= (n); ++j) {
      long long cur = -(sum[j] - sum[i]) + dp[2][j];
      if (cur > dp[1][i]) dp[1][i] = cur, act[1][i] = j;
    }
  }
  for (int i = (0); i <= (n); ++i) {
    dp[0][i] = LLONG_MIN, act[0][i] = -1;
    for (int j = (i); j <= (n); ++j) {
      long long cur = +(sum[j] - sum[i]) + dp[1][j];
      if (cur > dp[0][i]) dp[0][i] = cur, act[0][i] = j;
    }
  }
  int a = act[0][0], b = act[1][a], c = act[2][b];
  printf("%d %d %d\n", a, b, c);
}
int main() {
  run();
  return 0;
}
