#include <bits/stdc++.h>
using namespace std;
set<long long> primes;
long long n, m;
bool isvalid(long long x, long long y) {
  return (x >= 0 && x < n && y >= 0 && y < m);
}
long long dx[] = {0, 0, 1, -1, -1, 1, 1, -1};
long long dy[] = {1, -1, 0, 0, -1, 1, -1, 1};
void Sieve(long long n) {
  bool prime[n + 1];
  for (long long i = 0; i < n + 1; ++i) prime[i] = true;
  for (long long p = 2; p * p <= n; ++p) {
    if (prime[p] == true) {
      for (long long i = 2 * p; i <= n; i += p) prime[i] = false;
    }
  }
  for (long long p = 2; p <= n; p++)
    if (prime[p]) primes.insert(p);
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long powermod(long long x, long long y) {
  if (y == 0) return 1;
  if (y % 2 == 0)
    return (powermod(x, y / 2) * powermod(x, y / 2)) % 1000000007;
  else
    return (((powermod(x, y / 2) * powermod(x, y / 2)) % 1000000007) * x) %
           1000000007;
}
const long long N = 5005;
long long dp[N][7], a[N], pre[N];
long long r[N][7];
long long sol(long long l, long long part) {
  if (part == 3) {
    return -(pre[n] - pre[l - 1]);
  }
  long long &ans = dp[l][part];
  if (ans != LLONG_MIN) return ans;
  long long temp = -1e17, ind;
  for (long long i = l; i <= n + 1; i++) {
    long long cur = pre[i - 1] - pre[l - 1];
    long long t1 = 0;
    if (part == 0)
      t1 += cur;
    else if (part == 1)
      t1 = -cur;
    else
      t1 += cur;
    if (temp < t1 + sol(i, part + 1)) {
      temp = max(temp, t1 + sol(i, part + 1));
      ind = i;
    }
  }
  r[l][part] = ind;
  return ans = temp;
}
void solve() {
  memset(a, 0, sizeof a);
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 0; i <= n; i++)
    for (long long j = 0; j <= 6; j++) dp[i][j] = LLONG_MIN;
  for (long long i = 1; i <= n; i++) pre[i] += pre[i - 1] + a[i];
  vector<long long> t;
  long long ans = sol(1, 0);
  vector<long long> v1;
  long long ind = r[1][0];
  long long part = 1;
  while (part <= 3) {
    v1.push_back(ind);
    ind = r[ind][part];
    part++;
  }
  for (auto x : v1) cout << x - 1 << " ";
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) solve();
}
