#include <bits/stdc++.h>
using namespace std;
template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}
const int N = 5e3 + 7;
const long long INF = 1e18 + 7;
int n, T[N];
pair<long long, long long> solve(int a, int b) {
  int d = b - a;
  if (d == 0) return make_pair(0, a);
  vector<long long> t(d + 5, 0), pre(d + 5, 0), suf(d + 5, 0);
  for (int i = a; i < b; i++) t[i - a + 1] = T[i];
  for (int i = 1; i <= d; i++) pre[i] = pre[i - 1] + t[i];
  for (int i = d; i; i--) suf[i] = suf[i + 1] - t[i];
  pair<long long, long long> ans = {-INF, 0};
  for (int i = 1; i <= d + 1; i++)
    ans = max(ans, {pre[i - 1] + suf[i], a - 1 + i});
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> T[i];
  long long ans = -INF, id = 0;
  for (int i = 1; i <= n + 1; i++) {
    long long tmp = solve(1, i).first + solve(i, n + 1).first;
    if (tmp > ans) ans = tmp, id = i;
  }
  cout << solve(1, id).second - 1 << " " << id - 1 << " "
       << solve(id, n + 1).second - 1 << "\n";
  return 0;
}
