solution
#include <iostream>
using namespace std;
const int N = 10010;
int a[N];
int main()
{
int n;
cin >> n;
int temp = 0, ans = -1, tar1 = 0, tar2 = n - 1, tidx = 0;
for (int i = 0; i < n; i++)
{
cin >> a[i];
temp += a[i];
if (temp < 0)
{
temp = 0;
tidx = i + 1;
}
else if (temp > ans)
{
ans = temp;
tar1 = tidx;
tar2 = i;
}
}
if (ans < 0)
{
cout << 0 << " " << a[0] << " " << a[n - 1];
}
else
{
cout << ans << " " << a[tar1] << " " << a[tar2];
}
}