#include <bits/stdc++.h>
using namespace std;
long long a[6000], f[6000], d[6000];
int nm[6000];
int n;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) f[i] = f[i - 1] + a[i];
  long long mx = -1e18;
  d[n + 1] = mx;
  for (int i = n; i >= 0; i--) {
    if (f[i] > d[i + 1]) {
      d[i] = f[i];
      nm[i] = i;
    } else {
      d[i] = d[i + 1];
      nm[i] = nm[i + 1];
    }
  }
  int ans1 = 0, ans2 = 0, ans3 = 0;
  for (int i = 0; i <= n; i++)
    for (int j = i; j <= n; j++)
      if (2 * f[i] - 2 * f[j] + 2 * d[j] - f[n] > mx) {
        mx = 2 * f[i] - 2 * f[j] + 2 * d[j] - f[n];
        ans1 = i;
        ans2 = j;
        ans3 = nm[j];
      }
  cout << ans1 << " " << ans2 << " " << ans3 << "\n";
  return 0;
}
