#include <bits/stdc++.h>
using namespace std;
const long long INF = 10000000000000000;
int get(int x) {
  if (x % 2 == 1) return 1;
  return -1;
}
int a[5005];
long long p[5005];
long long dp[5005][5];
int last[5005][5];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  p[0] = 0;
  for (int i = 1; i <= n; i++) p[i] = p[i - 1] + a[i];
  for (int i = 0; i < 5005; i++)
    for (int j = 0; j < 5; j++) dp[i][j] = -INF;
  dp[0][0] = 0;
  dp[0][1] = 0;
  last[0][1] = 0;
  dp[0][2] = 0;
  last[0][1] = 0;
  dp[0][3] = 0;
  last[0][3] = 0;
  dp[0][4] = 0;
  last[0][4] = 0;
  for (int j = 1; j <= 4; j++) {
    for (int i = 1; i <= n; i++) {
      long long maxVal = dp[i][j - 1];
      int mSize = 0;
      for (int l = 0; l <= i; l++) {
        long long tmp = dp[l][j - 1] + get(j) * (p[i] - p[l]);
        if (tmp > maxVal) {
          maxVal = tmp;
          mSize = i - l;
        }
      }
      dp[i][j] = maxVal;
      last[i][j] = mSize;
    }
  }
  int loc = n;
  int b[3];
  b[2] = loc - last[loc][4] + 1;
  int place = b[2] - 1;
  b[1] = place - last[place][3] + 1;
  place = b[1] - 1;
  b[0] = place - last[place][2] + 1;
  cout << b[0] - 1 << " " << b[1] - 1 << " " << b[2] - 1 << endl;
}
