#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long ans = LONG_LONG_MIN;
  vector<long long> pre(n, 0);
  pre[0] = a[0];
  for (long long i = 1; i < n; i++) pre[i] = pre[i - 1] + a[i];
  unordered_map<long long, long long> m;
  for (long long i = 0; i <= n; i++) {
    long long mx = LONG_LONG_MIN;
    for (long long j = i; j <= n; j++) {
      long long x = 0, y = 0;
      if (i != j && i != n) {
        if (j == n)
          x = pre[j - 1];
        else
          x = pre[j] - a[j];
        if (i != 0) x -= pre[i - 1];
      }
      if (i != j && j != n) {
        y = pre[n - 1];
        if (j != 0) y -= pre[j - 1];
      }
      if ((x - y) > mx) {
        mx = x - y;
        m[i] = j;
      }
    }
  }
  long long ans1, ans2, ans3;
  for (long long i = 0; i <= n; i++) {
    for (long long j = i; j <= n; j++) {
      long long x = 0, y = 0;
      long long z = m[j];
      if (i != j && i != n) {
        x = pre[i] - a[i];
      }
      if (j != n) {
        y = pre[j] - a[j];
        if (i != 0) y -= pre[i - 1];
      }
      long long X = 0, Y = 0;
      if (j != z && j != n) {
        if (z == n)
          X = pre[z - 1];
        else
          X = pre[z] - a[z];
        if (j != 0) X -= pre[j - 1];
      }
      if (j != z && z != n) {
        Y = pre[n - 1];
        if (z != 0) Y -= pre[z - 1];
      }
      long long mx = x - y + (X - Y);
      if (mx > ans) {
        ans1 = i;
        ans2 = j;
        ans3 = z;
        ans = mx;
      }
    }
  }
  if ((-1) * pre[n - 1] > ans) {
    ans1 = 0;
    ans2 = 0;
    ans3 = 0;
  }
  cout << ans1 << " " << ans2 << " " << ans3;
}
