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


using LL = long long int;
using uLL = unsigned long long int;
using uint = unsigned int;
using ld = long double;

const int N = 307;
const int MINUS = 2000000;

LL A[N];

int main(){
	cin.tie(NULL);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> A[i];
	}
	vector <LL> ans((n*(n+1))/2+n), history((n*(n+1))/2+n+1);
	LL rating = 0;
	int pos = 1;
	history[0] = 0;
	for(int i = 1; i <= n; i++){
		LL need = A[i];
		//cout << "I " << i << '\n';
		for(int j = 1; j <= i; j++){
			LL inc = MINUS;
			for(int k = 1; k <= j; k++){
				inc = min(inc, history[pos-k]+A[k]-rating);
				//cout << k << " " << history[pos-k] << " " << A[k] << " " << rating << '\n';
			}
			if(j == i){
				if(need > inc){
					cout << "NIE\n";
					return 0;
				}
				inc = need;
			}
			ans[pos-1] = inc;
			rating += inc;
			need -= inc;
			history[pos] = rating;
			//cout << inc << '\n';
			pos++;
		}
		//cout << '\n';
		ans[pos-1] = -MINUS;
		rating -= MINUS;
		history[pos] = rating;
		pos++;
	}
	cout << "TAK\n";
	cout << ans.size() << '\n';
	for(auto x: ans){
		cout << x << " ";
	}
	cout << '\n';
	return 0;
}