#include <bits/stdc++.h>
using namespace std;
long long N, a[5010], dp[5010][4];
long long mn[4];
pair<long long, long long> p[5010][4];
long long f(long long i, long long di) {
  if (i == N) {
    return 0;
  }
  if (di == 3) {
    long long sum = 0;
    for (long long j = i; j < N; j++) {
      sum -= a[j];
    }
    dp[i][di] = sum;
    return sum;
  }
  if (dp[i][di] != -1) {
    return dp[i][di];
  }
  dp[i][di] = numeric_limits<long long>::min();
  long long curr = 0;
  for (long long j = i; j <= N; j++) {
    long long case1 = mn[di] * curr + f(j, di + 1);
    if (dp[i][di] < case1) {
      dp[i][di] = case1;
      p[i][di] = make_pair(j, di + 1);
    }
    curr += a[j];
  }
  return dp[i][di];
}
int main() {
  memset(dp, -1, sizeof(dp));
  cin >> N;
  for (long long i = 0; i < N; i++) cin >> a[i];
  mn[0] = 1;
  mn[1] = -1;
  mn[2] = 1;
  mn[3] = -1;
  for (long long i = 0; i < 4; i++) dp[N][i] = 0;
  long long ccur = 0;
  for (long long i = N - 1; i >= 0; i--) {
    ccur -= a[i];
    dp[i][3] = ccur;
  }
  for (long long i = N - 1; i >= 0; i--) {
    for (long long di = 2; di >= 0; di--) {
      dp[i][di] = numeric_limits<long long>::min();
      long long curr = 0;
      for (long long j = i; j <= N; j++) {
        long long case1 = mn[di] * curr + dp[j][di + 1];
        if (dp[i][di] < case1) {
          dp[i][di] = case1;
          p[i][di] = make_pair(j, di + 1);
        }
        curr += a[j];
      }
    }
  }
  pair<long long, long long> curr = {0, 0};
  vector<long long> ans(3);
  for (long long i = 0; i < 3; i++) {
    pair<long long, long long> newcurr = {p[curr.first][curr.second].first,
                                          p[curr.first][curr.second].second};
    ans[i] = newcurr.first;
    curr = newcurr;
  }
  cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
  return 0;
}
