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 <bits/stdc++.h>
using namespace std;

long long INF = -1e13;
vector<long long> result;
int tab[309];

bool check(int n) {
	int sum = 0;
	for(int i=0;i<n;i++) {
		sum += result[result.size()-i-1];
		if(sum > tab[i+1])
			return false;
	}
	return true;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	for(int i=1;i<=n;i++) 
		cin >> tab[i];
	result.push_back(tab[1]);
	for(int i=2;i<=n;i++) {
		result.push_back(INF);
		vector<int> tmp;
		int sum = 0;
		for(int j=result.size()-i;j<result.size()-1;j++) {
			tmp.push_back(result[j]);
			sum += result[j];
		}
		for(int x:tmp)
			result.push_back(x);
		result.push_back(tab[i] - sum);
		if(!check(i)) {
			cout << "NIE\n";
			return 0;
		}
	}
	cout << "TAK\n";
	cout << result.size() << "\n";
	for(long long x:result)
		cout << x << " ";
	cout << "\n";
}