#include<bits/stdc++.h>
using namespace std;
deque<int> que;
int m,n,k;
int sum[10000001];
int main()
{ freopen("subq.in","r",stdin);
freopen("subq.out","w",stdout);
scanf("%d",&n);
for (int i=1;i<=n;i++)
{ scanf("%d",&sum[i]);
sum[i]+=sum[i-1];
}
int s,e;
int dis=-0x7fffffff;
for (int i=1;i<=n;i++)
{ while (!que.empty()&&sum[i-1]<=sum[que.back()])
{ que.pop_back();
}
que.push_back(i-1);
if (dis<sum[i]-sum[que.front()])
{ dis=sum[i]-sum[que.front()];
s=que.front()+1;
e=i;
}
}
printf("%d\n%d\n%d",s,e,dis);
return 0;
}