#include <bits/stdc++.h>
using namespace std;
long long int a[5555];
long long int ps[5555];
pair<long long int, int> dp1[5555];
long long int sum(int l, int r) {
  if (r == 0) {
    return 0;
  }
  if (l == 0) {
    return ps[r - 1];
  }
  return ps[r - 1] - ps[l - 1];
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  ps[0] = a[0];
  for (int i = 1; i < n; i++) {
    ps[i] = a[i] + ps[i - 1];
  }
  long long int res = -100000000000000000;
  int r1, r2, r3;
  for (int i = 0; i <= n; i++) {
    dp1[i] = {sum(0, 0) - sum(0, i), 0};
    for (int j = 1; j <= i; j++) {
      dp1[i] = max(dp1[i], {sum(0, j) - sum(j, i), j});
    }
    for (int j = i; j <= n; j++) {
      long long int z = dp1[i].first + sum(i, j) - sum(j, n);
      if (z > res) {
        res = z;
        r1 = dp1[i].second;
        r2 = i;
        r3 = j;
      }
    }
  }
  cout << r1 << ' ' << r2 << ' ' << r3;
  return 0;
}
