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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define rep(i,p,k) for(ll i=p; i<k; i++)
#define per(i,p,k) for (ll i=k-1;i>=p;i--)

ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}

using namespace std;

const ll INF = 1000000000000;
const ll nINF = -INF;
vl t;

ll tab[400];

ll dodaj(int x) {
    t.pb(nINF);
    int start = t.size();
    t.pb(tab[0]);
    int sum = tab[0];
    rep(i, start+1, start+x) {
        int poi = i-1;
        ll ma = tab[0];
        int d = 0;
        int s = 0;
        while(poi-d >= start) {
            s += t[poi-d];
            ma = min(ma, tab[d+1]-s);
            d += 1;
        }
        t.pb(ma);
    }
    ll xd = 0;
    per(i, t.size()-x, t.size()) {
        xd+=t[i];
    }
    return xd;
}

int main() {
    int n;
    cin >> n;
    rep(i, 0, n) {
        cin >> tab[i];
    }
    bool czy = true;
    /*
    per(i, 1, n+1) {
        ll ile = dodaj(i);
        if (ile != tab[i-1])
            czy = false;
    }*/
    dodaj(n);

    //cout<<"OK"<<endl;
    rep(i, 1, n+1) {
        ll suma = 0;
        rep(j, 1, 1+i) {
            suma += t[j];
        }
        //cout<<suma<<endl;
        if(suma != tab[i-1]) {
            czy = false;
            //cout<<i<<" "<<suma<<" "<<tab[i-1]<<endl;
        }
    }
    /*
    for(ll i : t) {
        cout<<i<<" ";
    }
    cout<<endl;*/
    if(czy) {
        cout<<"TAK"<<endl;
        cout<<t.size()<<endl;
        rep(i, 0, t.size()) {
             cout<<t[i]<<" ";
        }
    }
    else
        cout<<"NIE";

}