#include <bits/stdc++.h>
using namespace std;
const long long BIG = 1e6 + 9;
long long n, a[BIG], cs1[BIG], cs2[BIG];
long long lb[BIG], rb[BIG];
long long ls[BIG], rs[BIG];
int main() {
  cin >> n;
  long long b[3] = {n, n, n};
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cs1[0] = a[0];
  for (int i = 1; i < n; i++) cs1[i] += cs1[i - 1] + a[i];
  cs2[n - 1] = a[n - 1];
  for (int i = n - 2; i >= 0; i--) cs2[i] += cs2[i + 1] + a[i];
  long long ans = cs1[n - 1];
  long long best = -1, bs = 0;
  for (int i = 0; i < n; i++) {
    if (cs1[i] > bs) {
      bs = cs1[i];
      best = i;
    }
    ls[i] = bs + bs - cs1[i];
    lb[i] = best;
  }
  if (ls[n - 1] > ans) {
    ans = ls[n - 1];
    b[0] = lb[n - 1] + 1;
    b[1] = n;
    b[2] = n;
  }
  best = n;
  bs = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (cs2[i] < bs) {
      bs = cs2[i];
      best = i;
    }
    rs[i] = cs2[i] - bs - bs;
    rb[i] = best;
  }
  for (int i = 0; i + 1 < n; i++) {
    long long tans = ls[i] + rs[i + 1];
    if (tans <= ans) continue;
    ans = tans;
    b[0] = lb[i] + 1;
    b[1] = i + 1;
    b[2] = rb[i + 1];
  }
  cout << b[0] << " " << b[1] << " " << b[2];
  return 0;
}
