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
#include <bits/stdc++.h>

using namespace std;

const int N = 1007;
const int INF = 1 << 30;

int n;
int in[N];
int dp[N];

void check (int* ans, int m) {
	for (int len = 1; len <= n; ++len) {
		int mx = -INF;
		for (int j = 0; j + len <= m; ++j)
			mx = max(mx, ans[j + len] - ans[j]);
		assert(mx == in[len]);
	}
}

int main () {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &in[i]);
	
	dp[0] = 0;
	for (int i = 1; i <= n; ++i) {
		dp[i] = in[i];
		for (int j = 1; j <= i; ++j)
			dp[i] = min(dp[i], in[j] + dp[i - j]);
		
		if (dp[i] < in[i]) {
			puts("NIE");
			exit(0);
		}
	}
	
//	check(dp, n);
	
	puts("TAK");
	printf("%d\n", n);
	for (int i = 1; i <= n; ++i)
		printf("%d ", in[i] - in[i - 1]);
	puts("");
	return 0;
}