#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(time(0));
const double eps = 1e-10;
const long long inf = 0x3f3f3f3f3f3f3f3fLL;
const long long N = 5e3 + 5;
const long long MOD = 1e9 + 7;
long long pw(long long b, long long p) {
  long long res = 1;
  while (p > 0) {
    if (p & 1) res = res * b;
    b = b * b;
    p >>= 1;
  }
  return res;
}
long long a[N], b[N];
pair<long long, long long> go(long long l, long long r) {
  memset(b, 0LL, sizeof(b));
  for (long long i = l; i <= r; i++) {
    b[i] = b[i - 1] + a[i];
  }
  pair<long long, long long> res;
  res.first = -inf;
  for (long long i = l - 1; i <= r; i++) {
    long long pref = b[i] - b[l - 1];
    long long suf = b[r] - pref;
    if (pref - suf > res.first) {
      res.first = pref - suf;
      res.second = i;
    }
  }
  return res;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long long d1, d2, d3, ans = -inf;
  for (long long i = 0; i <= n; i++) {
    pair<long long, long long> x = go(1, i);
    pair<long long, long long> y = go(i + 1, n);
    if (x.first + y.first > ans) {
      ans = x.first + y.first;
      d1 = x.second;
      d2 = i;
      d3 = y.second;
    }
  }
  cout << d1 << ' ' << d2 << ' ' << d3;
  return 0;
}
