#include <bits/stdc++.h>
using namespace std;
int main(int argv, char* args[]) {
  long long int n;
  cin >> n;
  long long int a[n];
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long int b[n];
  b[0] = a[0];
  for (long long int i = 1; i < n; i++) {
    b[i] = b[i - 1] + a[i];
  }
  long long int sum[n + 1][n + 1];
  for (long long int i = 0; i < n + 1; i++) {
    for (long long int j = i; j < n + 1; j++) {
      if (i == j) {
        sum[i][j] = 0;
      } else if (i == 0) {
        sum[i][j] = b[j - 1];
      } else {
        sum[i][j] = b[j - 1] - b[i - 1];
      }
    }
  }
  long long int ans[n];
  long long int temp[n], minarr[n];
  for (long long int i = 0; i < n; i++) {
    temp[i] = 0;
    minarr[i] = 0;
  }
  long long int ansind[n][3];
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < n; j++) {
      temp[j] = 0;
      minarr[j] = 0;
    }
    long long int flag = 0;
    minarr[i] = i;
    temp[i] = a[i];
    for (long long int j = i + 1; j < n; j++) {
      if (temp[j - 1] + a[j] < a[j]) {
        minarr[j] = j;
      } else {
        minarr[j] = minarr[j - 1];
      }
      temp[j] = max(temp[j - 1] + a[j], a[j]);
    }
    long long int minsum = INT_MIN, minind = i, minind2 = i;
    for (long long int j = i; j < n; j++) {
      if (temp[j] > minsum) {
        minsum = temp[j];
        minind = minarr[j];
        minind2 = j;
      }
    }
    ans[i] = sum[0][i] - sum[i][minind] + sum[minind][minind2 + 1] -
             sum[minind2 + 1][n];
    ansind[i][0] = i;
    if (minsum <= 0) {
      ansind[i][1] = i;
      ansind[i][2] = i;
    } else {
      ansind[i][1] = minind;
      ansind[i][2] = minind2 + 1;
    }
  }
  long long int ansi = 0, minans = 0;
  for (long long int i = 0; i < n; i++) {
    if (ans[i] > minans) {
      ansi = i;
      minans = ans[i];
    }
  }
  cout << ansind[ansi][0] << " " << ansind[ansi][1] << " " << ansind[ansi][2]
       << " " << endl;
}
