#include <bits/stdc++.h>
using namespace std;
long long n, a[5005], pf[5005], d[5005], r[5005], ans = -(long long)1e18, x, y,
                                                  z;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i], pf[i] = pf[i - 1] + a[i], d[i] = -(long long)1e18;
  for (int i = n; i >= 0; i--)
    for (int j = i; j >= 0; j--)
      if (d[j] < pf[i - 1] - pf[j - 1] - (pf[n - 1] - pf[i - 1]))
        d[j] = pf[i - 1] - pf[j - 1] - (pf[n - 1] - pf[i - 1]), r[j] = i;
  for (int i = 0; i <= n; i++)
    for (int j = i; j <= n; j++)
      if (ans < pf[i - 1] - (pf[j - 1] - pf[i - 1]) + d[j])
        ans = pf[i - 1] - (pf[j - 1] - pf[i - 1]) + d[j], x = i, y = j,
        z = r[j];
  cout << x << " " << y << " " << z << endl;
  return 0;
}
