#include <bits/stdc++.h>
using namespace std;
const int N = 5002;
int n;
int a[N];
int d[4];
int len[N];
long long L[N], R[N];
int main() {
  cin >> n;
  long long sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum += a[i];
    a[i] *= -1;
  }
  long long ans = sum;
  d[0] = n;
  d[1] = n;
  d[2] = n;
  if (ans < 0) {
    ans = -sum;
    for (int i = 0; i < 3; ++i) d[i] = 0;
  }
  L[0] = a[0];
  len[0] = 1;
  for (int i = 1; i < n; ++i) {
    if (L[i - 1] > 0) {
      L[i] = a[i] + L[i - 1];
      len[i] = len[i - 1] + 1;
    } else {
      L[i] = a[i];
      len[i] = 1;
    }
  }
  R[n - 1] = a[n - 1];
  for (int i = n - 2; i >= 0; --i) R[i] = R[i + 1] + a[i];
  for (int i = n; i >= 1; --i) {
    int in = -1;
    long long lans = -1000000000000000LL;
    for (int j = 0; j < i; ++j) {
      if (L[j] > lans) {
        lans = L[j];
        in = j;
      }
    }
    if (ans < sum + 2 * R[i] + 2 * lans) {
      ans = sum + 2 * (R[i] + lans);
      d[2] = i;
      d[1] = in + 1;
      d[0] = in - len[in] + 1;
    }
  }
  for (int i = 0; i < 3; ++i) cout << d[i] << " \n"[i == 2];
  return 0;
}
