#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
int n;
int arr[N];
int x, y, z;
long long ans;
long long pref[N];
long long sum(int x, int y) {
  if (y <= x) {
    return 0;
  }
  return (pref[y - 1] - (x > 0 ? pref[x - 1] : 0));
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", arr + i);
  }
  pref[0] = arr[0];
  for (int i = 1; i < n; i++) {
    pref[i] += pref[i - 1] + arr[i];
  }
  for (int i = 0; i <= n; i++) {
    for (int j = i, k = i; k <= n; k++) {
      if (sum(i, k) < sum(i, j)) {
        j = k;
      }
      if (sum(0, i) - sum(i, j) + sum(j, k) - sum(k, n) > ans) {
        ans = sum(0, i) - sum(i, j) + sum(j, k) - sum(k, n);
        x = i;
        y = j;
        z = k;
      }
    }
  }
  printf("%d %d %d\n", x, y, z);
  return 0;
}
