#include <bits/stdc++.h>
using namespace std;
long long int n, arr[5008], dp1[5008], dp2[5007], pre[5008];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (long long int i = 1; i <= n; i++) {
    cin >> arr[i];
    pre[i] = pre[i - 1] + arr[i];
  }
  for (long long int i = 1; i <= n; i++) {
    if (arr[i] <= 0) {
      dp1[i] = dp1[i - 1] - arr[i];
    } else {
      dp1[i] = max(dp1[i - 1] - arr[i], pre[i]);
    }
  }
  for (long long int i = n; i >= 1; i--) {
    if (arr[i] > 0) {
      dp2[i] = dp2[i + 1] + arr[i];
    } else {
      dp2[i] = max(dp2[i + 1] + arr[i], pre[i - 1] - pre[n]);
    }
  }
  long long int res = -100000000000000000, res1, t1;
  for (long long int i = 1; i <= n; i++) {
    t1 = dp1[i] + dp2[i + 1];
    if (t1 > res) {
      res = t1;
      res1 = i;
    }
  }
  for (long long int i = 0; i <= res1; i++) {
    if (pre[i] - (pre[res1] - pre[i]) == dp1[res1]) {
      cout << i << " ";
      break;
    }
  }
  cout << res1 << " ";
  for (long long int i = res1; i <= n; i++) {
    if (pre[i] - pre[n] + pre[i] - pre[res1] == dp2[res1 + 1]) {
      cout << i;
      break;
    }
  }
  return 0;
}
