#include <bits/stdc++.h>
using namespace std;
long long dp[5005][5];
long long arr[5005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%lld", &arr[i]);
  arr[n + 1] = 0;
  dp[0][0] = dp[0][1] = dp[0][2] = dp[0][3] = 0;
  for (int i = 1; i <= n + 1; ++i) {
    dp[i][0] = dp[i - 1][0] + arr[i];
    dp[i][1] = max(dp[i - 1][0], dp[i - 1][1]) - arr[i];
    dp[i][2] = max(dp[i - 1][0], max(dp[i - 1][1], dp[i - 1][2])) + arr[i];
    dp[i][3] =
        max(max(dp[i - 1][0], dp[i - 1][1]), max(dp[i - 1][2], dp[i - 1][3])) -
        arr[i];
  }
  int ans[4];
  int now = n + 1;
  int index = 3;
  while (index >= 0) {
    if (index == 3) {
      if (dp[now][3] == dp[now - 1][2] - arr[now]) {
        ans[3] = now;
        index = 2;
      } else if (dp[now][3] == dp[now - 1][1] - arr[now]) {
        ans[3] = ans[2] = now;
        index = 1;
      } else if (dp[now][3] == dp[now - 1][0] - arr[now]) {
        ans[1] = ans[2] = ans[3] = now;
        break;
      } else
        now--;
    } else if (index == 2) {
      if (dp[now][2] == dp[now - 1][1] + arr[now]) {
        ans[index] = now;
        index = 1;
      } else if (dp[now][2] == dp[now - 1][0] + arr[now]) {
        ans[index] = ans[index - 1] = now;
        break;
      } else
        now--;
    } else if (index == 1) {
      if (dp[now][1] == dp[now - 1][0] - arr[now]) {
        ans[index] = now;
        break;
      }
      now--;
    }
  }
  for (int i = 1; i <= 3; ++i) {
    printf("%d ", ans[i] - 1);
  }
  return 0;
}
