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

#define debug if(0)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

int n;
int tab[303];
long long int odp[303], pref[303];

void NIE() {
    puts ("NIE");
    exit(0);
}
int main() {
    
    cin >> n;
    
    for (int i = 1; i <= n; ++i) {
        cin >> tab[i];
    }
    
    pref[1] = odp[1] = tab[1];
    
    for (int i = 2; i <= n; ++i) {
        odp[i] = tab[i] - pref[i - 1];
        pref[i] = pref[i - 1] + odp[i];
        
        //printf ("i=%d odp[i]=%lld pref[i]=%lld\n", i, odp[i], pref[i]);
        
        for (int j = i; j >= 1; --j) {
            if (pref[i] - pref[j - 1] > tab[i - j + 1]) {
                NIE();
            }
        }
    }
    
    puts ("TAK");
    printf ("%d\n", n);
    
    for (int i = 1; i <= n; ++i) {
        printf ("%lld ", odp[i]);
    }
    
    return 0;
}
/*
10
3 1 4 1 5 9 2 6 5 3
*/