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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <bits/stdc++.h>
using namespace std;
typedef long long lld;
typedef double lf;
typedef long double llf;
typedef pair<int,int> pii;
typedef pair<lld,lld> pll;
#define For(i,s,a) for(int i = (int)s; i < (int)a; ++i)
#define rpt(s, it) for(auto it = s.begin(); it != s.end(); ++it)
#define brpt(s, it) for(auto it = s.rend(); it != s.rbegin(); --it)
#define sz size()
#define pb push_back
#define eb emplace_back
#define ff first
#define dd second
#define mp make_pair
#define all(x) (x).begin (x).end()

template<typename Ta, typename Tb>
ostream & operator <<(ostream & os, pair<Ta, Tb> x){
	return os << x.ff << " " << x.dd;
}

lld c[301];

const lld minf = -5000000000000ll;

lld wyn[100001];
lld dp[302];
lld seq[302];

int32_t main(void){
	int a;
	scanf("%d", &a);
	//For(i, 0, a)
	//	scanf("%d", &seq[i]);
	For(i, 0, a)
		scanf("%lld", &c[i]);
	c[a] = 0;
	For(i, 0, a)
		wyn[i] = c[i] - (i ? c[i - 1] : 0);
	For(len, 1, a + 1){
		dp[len] = -10000000000000ll;
		For(pos, 0, a + 1 - len){
			lld sum = 0;
			For(j, pos, pos + len)
				sum += wyn[j];
			dp[len] = max(dp[len], sum);
		}
	}
	For(i, 1, a + 1){
		///cout<<c[i - 1]<<" "<<dp[i]<<endl;
		if(c[i - 1] != dp[i]){
			puts("NIE");
			return 0;
		}
	}
	puts("TAK");
	printf("%d\n", a);
	For(i, 0, a)
		printf("%lld ", wyn[i]);
}

/*
10
3 1 4 1 5 9 2 6 5 3
*/