#include <bits/stdc++.h>
using namespace std;
const int maxn = 50050;
const long long inf = 1e18;
long long a[maxn], sum[maxn], mar[maxn][20];
int n;
void buildRMQ() {
  for (int j = 0; j <= n; ++j) mar[j][0] = sum[j];
  int m = (int)floor(log((double)n) / log(2.0));
  for (int i = 1; i <= m; ++i) {
    for (int j = 0; j + (1 << (i - 1)) <= n; ++j) {
      mar[j][i] = max(mar[j][i - 1], mar[j + (1 << (i - 1))][i - 1]);
    }
  }
}
long long RMQ(int l, int r) {
  int m = (int)floor(log((double)(r - l + 1)) / log(2.0));
  return max(mar[l][m], mar[r - (1 << m) + 1][m]);
}
int main() {
  while (~scanf("%d", &n)) {
    sum[0] = 0;
    for (int i = 1; i <= n; ++i) scanf("%lld", a + i);
    for (int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + a[i];
    buildRMQ();
    long long a = 0, b = 0, c = 0, cnt = 0;
    for (int i = n; i >= 1; --i) {
      for (int j = i; j >= 1; --j) {
        long long temp = RMQ(1, j);
        if (temp - sum[j] + sum[i] > cnt) {
          a = temp, b = j, c = i;
          cnt = temp - sum[j] + sum[i];
        }
        if (sum[i] - sum[j] > cnt) {
          a = 0, b = j, c = i;
          cnt = sum[i] - sum[j];
        }
      }
      if (sum[i] > cnt) {
        a = 0, b = 0, c = i;
        cnt = sum[i];
      }
    }
    for (int i = 0; i <= b; ++i) {
      if (sum[i] == a) {
        a = i;
        break;
      }
    }
    printf("%lld %lld %lld\n", a, b, c);
  }
  return 0;
}
