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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "kanapka.h"
#include "message.h"
#include <iostream>

using namespace std;

int main()
{
	int n1 = NumberOfNodes();
	int n2 = MyNodeId();
	long long a = GetN();
	a--;

	if (n2 == 0){}
	else{ return 0; }

	
	long long sum = 0, min1 = 0, sum1 = 0;
	long long targets1 = 0, targets2 = a;

	
	min1 = GetTaste(0);
	for (long long i = 0; i <= a; i++){
		sum += GetTaste(i);
		if (sum<=min1)
		{
			min1 = sum;
			sum1 = sum;
			targets2 = i;
		}
	}

	for (long long i = 0; i <= targets2; i++)
	{
		if (sum1 <= min1)
		{
			min1 = sum1;
			targets1 = i;
		}
		sum1 -= GetTaste(i);
	}
	
	sum -= min1;
	cout << sum;


	return 0;
}