#include <bits/stdc++.h>
using namespace std;
inline bool eq(double a, double b) { return fabs(a - b) < 1e-9; }
const long long int inf = 1e15;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n >> b) & 1; }
inline void set_bit(int& n, int b) { n |= two(b); }
inline void unset_bit(int& n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) {
  int res = 0;
  while (n && ++res) n -= n & (-n);
  return res;
}
int n;
vector<long long int> ar(5002), sum(5002, 0);
void solve() {
  long long int ans = -inf, oa, ob, oc;
  for (int a = 0; a <= n; a++) {
    int b = a;
    for (int c = a; c <= n; c++) {
      if (sum[c] < sum[b]) b = c;
      long long int cans = 2 * (sum[a] - sum[b] + sum[c]);
      if (cans > ans) {
        ans = cans;
        oa = a, ob = b, oc = c;
      }
    }
  }
  cout << oa << " " << ob << " " << oc << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < (n); i++) cin >> ar[i];
  for (int i = (1); i <= (n); i++) sum[i] = sum[i - 1] + ar[i - 1];
  solve();
  return 0;
}
