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
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <vector>

using namespace std;

const int64_t INF = 1000000000000000LL;

int main () {
	int n;
	scanf("%d", &n);
	vector<int64_t> a;
	for (int i = 0; i < n; ++i) {
		int64_t x;
		scanf("%lld", &x);
		a.push_back(x);
	}
	vector<int64_t> b;
	b.reserve(102000);
	for (int i = 0; i < 500; ++i) {
		b.push_back(-INF);
	}
	vector<int64_t> sums;
	int64_t s = 0;
	for (int i = 0; i < n; ++i) {
		sums.push_back(s);
		s -= INF;
	}
	vector<bool> ok;
	for (int i = 0; i < n; ++i) {
		ok.push_back(false);
	}
	for (int i = 0; i < 100500; ++i) {
		int64_t next = INF;
		for (int j = 0; j < n; ++j) {
			int64_t m = a[j] - sums[j];
			if (m < next) {
				next = m;
			}
		}
		b.push_back(next);
		for (int j = 0; j < n; ++j) {
			sums[j] += next - b[b.size() - j - 1];
			if ((j > 0) && (sums[j] == a[j - 1])) {
				ok[j] = true;
			}
		}
	}
	for (int i = 1; i < n; ++i) {
		if (!ok[i]) {
			printf("NIE\n");
			return 0;
		}
	}
	printf("TAK\n100000\n");
	for (int i = 0; i < 100000; ++i) {
		printf("%lld", b[500 + i]);
		if (i < 99999) {
			printf(" ");
		}
	}
	printf("\n");
	return 0;
}