#include <bits/stdc++.h>
using namespace std;
const int MAX = 5003;
long long arr[MAX];
long long pre[MAX];
long long mx[MAX];
int ind[MAX];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &arr[i]);
  }
  for (int i = 1; i <= n; i++) {
    pre[i] = pre[i - 1] + arr[i];
  }
  for (int i = 1; i <= (n + 1); i++) {
    mx[i] = -1e15;
    for (int j = i; j <= (n + 1); j++) {
      if ((pre[j - 1] - pre[i - 1] - pre[n] + pre[j - 1]) > mx[i]) {
        ind[i] = j - 1;
        mx[i] = (pre[j - 1] - pre[i - 1] - pre[n] + pre[j - 1]);
      }
    }
  }
  int ind1, ind2, ind3;
  long long ans = -1e15;
  for (int i = 1; i <= (n + 1); i++) {
    for (int j = i; j <= (n + 1); j++) {
      long long tmp = pre[i - 1] - pre[0];
      tmp -= (pre[j - 1] - pre[i - 1]);
      tmp += mx[j];
      if (tmp > ans) {
        ind1 = i - 1;
        ind2 = j - 1;
        ind3 = ind[j];
        ans = tmp;
      }
    }
  }
  printf("%d %d %d\n", ind1, ind2, ind3);
  return 0;
}
