#include <bits/stdc++.h>
using namespace std;
const int INF32 = 1E9;
const long long INF64 = 4E18;
const long long M = 1E9 + 7;
const double EPS = 1E-9;
const double PI = 2 * acos(0);
pair<long long, long long> max_sum(vector<long long>& a, int s, int e) {
  long long sum = 0;
  long long mn = INF64;
  pair<long long, long long> ans;
  int start = s, finish;
  for (int i = s; i < e; ++i) {
    if (sum >= 0) start = i;
    sum += a[i];
    finish = i + 1;
    if (sum > 0) {
      sum = 0;
      finish = i;
    }
    if (sum < mn) {
      mn = sum;
      ans = pair<long long, long long>(start, finish);
    }
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  if (fopen("tupni.txt", "r")) {
    freopen("tupni.txt", "r", stdin);
    freopen("tuptuo.txt", "w", stdout);
  }
  int n;
  cin >> n;
  vector<long long> a(n + 1, 0);
  vector<long long> ps(n + 1, 0);
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    ps[i] += ps[i - 1] + a[i];
  }
  long long all = ps[n];
  long long s4 = 0;
  long long mx = all;
  vector<long long> ans(3, n + 1);
  for (int i = n; i >= 0; --i) {
    pair<long long, long long> seg = max_sum(a, 1, i + 1);
    long long s2 = ps[seg.second - 1] - ps[seg.first - 1];
    long long res = all - 2 * s4 - 2 * s2;
    if (res > mx) {
      mx = res;
      ans[0] = seg.first;
      ans[1] = seg.second;
      ans[2] = i + 1;
    }
    s4 += a[i];
  }
  for (int i = 0; i < 3; ++i) {
    cout << ans[i] - 1 << ' ';
  }
  cout << '\n';
  return 0;
}
