#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5052;
const long long INF = (1LL << 60);
int a[MAXN], n;
long long sum[MAXN];
pair<long long, pair<pair<int, int>, int>> best = {-INF, {{0, 0}, 0}};
pair<long long, pair<int, int>> getsecondbest(int idx) {
  pair<long long, pair<int, int>> res = {-INF, {0, 0}};
  pair<long long, long long> mn = {INF, 0};
  for (int i = idx; i <= n; i++) {
    mn = min(mn, {sum[i], i});
    if (sum[i] - mn.first > res.first) {
      res = {sum[i] - mn.first, {mn.second, i}};
    }
  }
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum[i] = sum[i - 1] + a[i];
  }
  for (int i = 0; i <= n; i++) {
    pair<long long, pair<int, int>> cur = getsecondbest(i);
    if (cur.first + sum[i] > best.first) {
      best = {cur.first + sum[i], {{i, cur.second.first}, cur.second.second}};
    }
  }
  printf("%d %d %d\n", best.second.first.first, best.second.first.second,
         best.second.second);
  return 0;
}
