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
#include <bits/stdc++.h>
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define TRAV(i, a) for(auto & i : (a))
#define SZ(x) ((int)(x).size())
#define PR std::pair
#define MP std::make_pair
#define X first
#define Y second
typedef long long ll;
typedef std::pair<int, int> PII;
typedef std::vector<int> VI;

const ll INF = 1000000666ll*1000000000ll;

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

	int n;
	std::cin >> n;
	std::vector<ll> A(n);
	FOR(i, n){
		std::cin >> A[i];
	}

	std::vector<ll> pref(n+1, INF);
	pref[0] = 0;
	REP(i, 1, n+1){
		REP(j, 1, i+1){
			pref[i] = std::min(pref[i], pref[i-j] + A[j-1]);
		}
	}

	std::vector<ll> ans(n);
	FOR(i, n) ans[i] = pref[i+1]-pref[i];

	std::vector<ll> check(n, -INF);
	REP(sz, 1, n+1){
		REP(i, sz, n+1){
			check[sz-1] = std::max(check[sz-1], pref[i]-pref[i-sz]);
		}
		assert(check[sz-1] <= A[sz-1]);
		if(check[sz-1] < A[sz-1]){
			std::cout << "NIE\n";
			return 0;
		}
	}

	std::cout << "TAK\n";
	std::cout << n << "\n";
	FOR(i, n){
		if(i != 0) std::cout << " ";
		std::cout << ans[i];
	}
	std::cout << "\n";

	return 0;
}