#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
void solve() {
  long long int n, a;
  cin >> n;
  vector<long long int> v;
  for (long long int i = 0; i < n; i++) {
    cin >> a;
    v.push_back(a);
  }
  v.push_back(0);
  vector<long long int> pref(n + 2, 0), suff(n + 2, 0);
  pref[0] = v[0];
  for (long long int i = 1; i < n; i++) {
    pref[i] = pref[i - 1] + v[i];
  }
  pref[n] = pref[n - 1];
  suff[n - 1] = v[n - 1];
  for (long long int i = n - 2; i >= 0; i--) {
    suff[i] = suff[i + 1] + v[i];
  }
  vector<vector<long long int>> dp(5, vector<long long int>(n + 2, 0));
  vector<vector<long long int>> ind(5, vector<long long int>(n + 2, 0));
  for (long long int i = 1; i <= n; i++) {
    dp[1][i] = pref[i - 1];
    ind[1][i] = i;
  }
  for (long long int i = 2; i <= 3; i++) {
    for (long long int j = 0; j <= n; j++) {
      long long int val = -1e16;
      for (long long int k = 0; k <= j; k++) {
        long long int p = dp[i - 1][k];
        long long int q = pref[j] - pref[k] - v[j] + v[k];
        if (i == 2) {
          q = -q;
        }
        p += q;
        if (i == 3) {
          p -= suff[j];
        }
        if (p > val) {
          val = p;
          ind[i][j] = k;
        }
      }
      dp[i][j] = val;
    }
  }
  long long int mx = -1e16;
  long long int ans[4];
  for (long long int i = 0; i <= n; i++) {
    if (dp[3][i] > mx) {
      mx = dp[3][i];
      ans[3] = i;
      ans[2] = ind[3][i];
      ans[1] = ind[2][ans[2]];
    }
  }
  cout << ans[1] << " " << ans[2] << " " << ans[3] << endl;
}
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
