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
66
67
#include<iostream>
#include<string>
#include<vector>

using namespace std;

const string MniejNizZero = "-10000000000000";
const int MAXN = 300;

vector<int> ciagi[MAXN];
int suma[MAXN];
int dlugosc_ciagu = 0;

int n;

void check(int a)
{
	for (int i = 0; i < a; i++)
	{
		int s = suma[a] - suma[a - 1 - i];
		if (s > suma[i])
		{
			cout << "NIE" << endl;
			exit(0);
		}
	}
}

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

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		suma[i] = a;
		if (i == 0)
		{
			ciagi[0].push_back(a);
			dlugosc_ciagu += 2;
		}
		else
		{
			vector<int> ciag = ciagi[i - 1];
			int nowa_liczba = a - suma[i-1];
			ciag.push_back(nowa_liczba);
			ciagi[i] = ciag;
			check(i);
			dlugosc_ciagu += ciag.size() + 1;
		}
	}
	cout << "TAK" << endl;
	cout << dlugosc_ciagu << endl;
	for (int i = 0; i < n; i++)
	{
		for (auto b : ciagi[i])
		{
			cout << b << " ";
		}
		cout << MniejNizZero << " ";
	}
	return 0;
}