#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f3f3f3f;
const int T = 5e4 + 5;
long long v[T];
long long dp[T][5];
int escolha[T][5];
int n;
long long solve(int at, int p) {
  if (at == n) return (p == 3 ? 0 : -INF);
  long long &r = dp[at][p];
  if (r != -1) return r;
  long long x = (p & 1 ? -v[at] : v[at]);
  long long k = solve(at + 1, p) + x;
  long long t = -INF;
  if (p < 3) t = solve(at + 1, p + 1) + x;
  long long ans = max(k, t);
  if (k >= t)
    escolha[at][p] = 0;
  else
    escolha[at][p] = 1;
  return r = ans;
}
void build(int at, int p) {
  if (at >= n) return;
  if (escolha[at][p]) cout << at + 1 << " ";
  build(at + 1, p + escolha[at][p]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  memset(dp, -1, sizeof dp);
  for (int i = 0; i < n; i++) cin >> v[i];
  long long ans = 0;
  long long k = 0;
  int ini = 0;
  for (int i = 0; i < 4; i++) {
    k = solve(0, i);
    if (k >= ans) ini = i;
    ans = max(ans, k);
  }
  for (int i = 0; i < ini; i++) cout << 0 << " ";
  build(0, ini);
  cout << endl;
  return 0;
}
