#include <bits/stdc++.h>
using namespace std;
int n;
vector<long long> arr;
vector<long long> suff;
long long ans = 0;
int main() {
  cin >> n;
  arr.resize(n);
  suff.resize(n + 1);
  vector<long long> sum_left(n + 2, 0);
  vector<long long> sum_right(n + 2, 0);
  vector<int> ll(n + 2, 0);
  vector<int> rr(n + 2, n);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    suff[i + 1] = suff[i] + arr[i];
    ll[i + 1] = i + 1;
    sum_left[i + 1] = suff[i + 1];
  }
  vector<long long> rig(n + 2, 0);
  for (int i = n - 1; i >= 0; --i) {
    rig[i + 1] = rig[i + 1 + 1] - arr[i];
    rr[i + 1] = i;
    sum_right[i + 1] = rig[i + 1];
  }
  long long tot = 0;
  for (int i = n - 1; i >= 0; --i) {
    tot = 0;
    for (int j = i; j < n; ++j) {
      tot += arr[j];
      if (rig[i + 1] < (tot + sum_right[j + 2])) {
        rig[i + 1] = tot + sum_right[j + 2];
        rr[i + 1] = j + 1;
      }
    }
  }
  tot = 0;
  for (int i = 0; i < n; ++i) {
    tot = 0;
    for (int j = i; j >= 0; --j) {
      tot += arr[j];
      if (suff[i + 1] < sum_left[j] - tot) {
        suff[i + 1] = sum_left[j] - tot;
        ll[i + 1] = max(0, j);
      }
    }
  }
  long long ans = LLONG_MIN;
  int mid = 0;
  int l = mid, r = n;
  for (int i = 0; i <= n; ++i) {
    if (ans < (suff[i] + rig[i + 1])) {
      ans = suff[i] + rig[i + 1];
      mid = i;
      l = ll[i];
      r = rr[i + 1];
    }
  }
  cout << l << " " << mid << " " << r << endl;
}
