#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int INF = 1e9;
vector<long long> sum(N);
long long sumLR(int l, int r) {
  if (l > r) return 0;
  return sum[r] - sum[l];
}
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  sum[0] = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum[i + 1] = sum[i] + a[i];
  }
  long long s = -INF;
  int id1 = -1;
  int id2 = -1;
  int id3 = -1;
  for (int i = 0; i < n; i++) {
    long long ts = 0;
    long long tmpsum = 0;
    int tl = i;
    int tr = i;
    int l = i;
    int r = i;
    for (int j = i; j < n; j++) {
      if (tmpsum < 0) {
        tmpsum = 0;
        tl = j;
        tr = j;
      }
      tmpsum += a[j];
      if (tmpsum > ts) {
        ts = tmpsum;
        tr = j + 1;
        l = tl;
        r = tr;
      }
    }
    if (tmpsum > ts) {
      ts = tmpsum;
      tr = n;
      l = tl;
      r = tr;
    }
    long long s2 = 0;
    for (int j = i; j < n; j++)
      if (j < l || j >= r) s2 += a[j];
    if (sumLR(0, i) + ts - s2 > s) {
      s = sumLR(0, i) + ts - s2;
      id1 = i;
      id2 = l;
      id3 = r;
    }
  }
  cout << id1 << ' ' << id2 << ' ' << id3 << endl;
}
