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
//Marcin Wróbel
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,x,y) for(int i = (int)(x); i < (int)(y); ++i)
#define FORE(i,x,y) for(int i = (int)(x); i <= (int)(y); ++i)
#define FORD(i,x,y) for(int i = (int)(x); i >= (int)(y); --i)
#define PB push_back
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN=307;
const int INF=1e9;
int n;
int a[MAXN];
int b[MAXN];
bool c[MAXN];
int res[MAXN];
int sum(int v,int w) {
    return b[w]-b[v-1];
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n;
    FORE(i,1,n) cin>>a[i];
    FORE(i,1,n) {
        int mx=INF;
        FORE(j,1,i) {
            int sm = sum(j,i-1);
            mx=min(mx,a[i-j+1] - sm);
            if (sm == a[i-j]) c[i-j] = true;
        }
        res[i] = mx;
        b[i] = mx + b[i-1];
    }
    FORE(j,1,n){
        int sm = sum(j,n);
        if (sm == a[n-j+1]) c[n-j+1] = true;
    }
    FORE(i,1,n) {
        if (!c[i]) {
            cout<<"NIE\n";
            return 0;
        }
    }
    cout<<"TAK\n"<<n<<"\n";
    FORE(i,1,n) cout<<res[i]<<" ";
    cout<<"\n";
    return 0;
}

/*
9
3 4 3 1 2 3 2 0 1


*/