#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
int lcm(int x, int y) { return x / gcd(x, y) * y; }
int lowbit(int x) { return x & (-x); }
int quickmod(int x, int y, int mod) {
  x = x % mod;
  int ans = 1;
  while (y) {
    if (y & 1) ans = 1LL * ans * x % mod;
    y >>= 1;
    x = 1LL * x * x % mod;
  }
  return ans;
}
const int INF = 0x3f3f3f3f;
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int MOD = 1e9 + 7;
long long n;
long long num[5005], sum[5005];
pair<long long, long long> xiao1[5005], xiao2[5005];
int main() {
  scanf("%I64d", &n);
  for (int i = 0; i <= n + 2; i++) xiao1[i].first = xiao2[i].first = 1e15;
  for (int i = 0; i < n; i++) scanf("%I64d", &num[i]);
  sum[n] = 0;
  for (int i = n - 1; i >= 0; i--) sum[i] = sum[i + 1] + num[i];
  xiao1[0].first = sum[0];
  xiao1[0].second = 0;
  for (long long i = 1; i <= n; i++) {
    if (sum[i] < xiao1[i - 1].first)
      xiao1[i].first = sum[i], xiao1[i].second = i;
    else
      xiao1[i] = xiao1[i - 1];
  }
  xiao2[n].first = sum[n];
  xiao2[n].second = n;
  for (long long i = n - 1; i >= 0; i--) {
    if (sum[i] < xiao2[i + 1].first)
      xiao2[i].first = sum[i], xiao2[i].second = i;
    else
      xiao2[i] = xiao2[i + 1];
  }
  long long zong = -1e15;
  long long ans1, ans2, ans3;
  for (long long d1 = 0; d1 <= n; d1++) {
    long long d0 = xiao1[d1].second;
    long long d2 = xiao2[d1].second;
    if (sum[0] + 2 * (sum[d1] - sum[d0] - sum[d2]) > zong) {
      zong = sum[0] + 2 * (sum[d1] - sum[d0] - sum[d2]);
      ans1 = d0;
      ans2 = d1;
      ans3 = d2;
    }
  }
  printf("%I64d %I64d %I64d\n", ans1, ans2, ans3);
  return 0;
}
