#include <bits/stdc++.h>
using namespace std;
long long sum[5050];
int main() {
  long long n, ans1, ans2, ans, res1, res2;
  long long pos0, pos1, pos2, fin0, fin1, fin2;
  scanf("%lld", &n);
  for (long long i = 0; i < n; i++) {
    long long x;
    scanf("%lld", &x);
    sum[i + 1] = x + sum[i];
  }
  ans = ans1 = ans2 = -1100000000;
  for (long long i = 0; i <= n; i++) {
    res1 = 0;
    res2 = 0;
    pos1 = i;
    ans1 = ans2 = -1100000000;
    for (long long j = 0; j <= i; j++) {
      res1 = sum[j] * 2 - sum[i];
      if (ans1 < res1) {
        ans1 = res1;
        pos0 = j;
      }
    }
    for (long long j = i; j <= n; j++) {
      res2 = sum[j] - sum[i] - (sum[n] - sum[j]);
      if (ans2 < res2) {
        ans2 = res2;
        pos2 = j;
      }
    }
    if (ans1 + ans2 > ans) {
      ans = ans1 + ans2;
      fin0 = pos0;
      fin1 = pos1;
      fin2 = pos2;
    }
  }
  printf("%lld %lld %lld\n", fin0, fin1, fin2);
  return 0;
}
