1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <bits/stdc++.h>
#include "kanapka.h"
#include "message.h"
typedef long long ll;
using namespace std;
int main()
{
    ll n;
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    //cin >> n;
    n = GetN();
    ll suma = 0;
    ll miniest = 0;
    ll curr = 0;
    for(ll i = 0; i < n; i++){
        ll x;
        //cin >> x;
        x = GetTaste(i);
        suma+=x;
        curr+=x;
        if(curr>=0)
            curr=0;
        miniest=min(curr, miniest);
    }
    cout <<suma-miniest << endl;
    return 0;
}