#include <bits/stdc++.h>
using namespace std;
long long arr[5005];
long long pre[5005];
long long res[5005];
int suf[5005];
long long get(int i, int j) {
  if (i == j) return 0;
  --j;
  return pre[j] - (i ? pre[i - 1] : 0);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
  int n;
  cin >> n;
  for (int i = (0); i <= (n - 1); ++i) cin >> arr[i];
  for (int i = (0); i <= (n - 1); ++i) {
    pre[i] = arr[i];
    if (i) pre[i] += pre[i - 1];
  }
  for (int i = (0); i <= (n - 1); ++i) res[i] = -1e18;
  for (int i = (0); i <= (n); ++i) {
    for (int j = (i); j <= (n); ++j) {
      long long r = get(i, j) - get(j, n);
      if (r > res[i]) {
        res[i] = r;
        suf[i] = j;
      }
    }
  }
  int x, y, z;
  long long ans = -1e18;
  for (int i = (0); i <= (n); ++i) {
    for (int j = (i); j <= (n); ++j) {
      long long r1 = get(0, i);
      long long r2 = get(i, j);
      long long r3 = res[j];
      long long f = r1 - r2 + r3;
      if (f > ans) {
        ans = f;
        x = i, y = j, z = suf[j];
      }
    }
  }
  cout << x << " " << y << " " << z << endl;
  return 0;
}
