#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int n;
  cin >> n;
  long long int a[n + 1];
  for (long long int i = 1; i <= n; i++) cin >> a[i];
  long long int pre[n + 1], suf[n + 2], mn[n + 2], mni[n + 2];
  pre[0] = suf[n + 1] = 0;
  mn[n + 1] = 0, mni[n + 1] = n;
  for (long long int i = 1; i <= n; i++) pre[i] = pre[i - 1] + a[i];
  for (long long int i = n; i > 0; i--) {
    suf[i] = suf[i + 1] + a[i];
    if (suf[i] < mn[i + 1]) {
      mn[i] = suf[i];
      mni[i] = i - 1;
    } else {
      mn[i] = mn[i + 1];
      mni[i] = mni[i + 1];
    }
  }
  long long int mx = 0, p1 = 0, p2 = 0, p3 = 0;
  for (long long int i = 0; i <= n; i++) {
    for (long long int j = i; j <= n; j++) {
      long long int val = 2 * pre[i] - pre[j] + suf[j + 1] - 2 * mn[j + 1];
      if (val > mx) {
        mx = val;
        p1 = i, p2 = j, p3 = mni[j + 1];
      }
    }
  }
  cout << p1 << " " << p2 << " " << p3 << '\n';
}
