#include <bits/stdc++.h>
using namespace std;
long long n, ansi, ansj, ansk;
long long a[5010];
signed main() {
  long long ans = (-(1ll << 62));
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    a[i] += a[i - 1];
  }
  long long ki, kk, sum1, sum2, sum3;
  for (long long j = 0; j <= n; j++) {
    sum2 = a[j];
    sum3 = a[n], kk = n;
    for (long long i = n; i >= j; i--) {
      if (sum3 < a[i]) sum3 = a[i], kk = i;
    }
    sum1 = a[0], ki = 0;
    for (long long i = 0; i <= j; i++) {
      if (sum1 < a[i]) sum1 = a[i], ki = i;
    }
    if (sum1 + sum3 - sum2 > ans)
      ans = sum1 + sum3 - sum2, ansi = ki, ansj = j, ansk = kk;
  }
  printf("%lld %lld %lld\n", ansi, ansj, ansk);
  return 0;
}
