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
// valentine's day code
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, a, n) for (int i = a; i < (int)(n); i++)
#define per(i, a, n) for (int i = (n)-1; i >= (int)(a); i--)
template <typename T, typename U>
ostream& operator<<(ostream& _s, pair<T, U> _t) {
    _s << "(" << _t.first << "," << _t.second << ")";
    return _s;
}
template <typename T, typename U>
istream& operator>>(istream& _s, pair<T, U>& _t) {
    _s >> _t.first >> _t.second;
    return _s;
}
template <typename T>
ostream& operator<<(ostream& _s, vector<T> _t) {
    rep(i, 0, _t.size()) _s << (i ? " " : "") << _t[i];
    return _s;
}
template <typename T>
istream& operator>>(istream& _s, vector<T>& _t) {
    rep(i, 0, _t.size()) _s >> _t[i];
    return _s;
}
template <typename T>
ostream& operator<<(ostream& _s, vector<vector<T>> _t) {
    rep(i, 0, _t.size()) { _s << i << ": " << _t[i] << endl; }
    return _s;
}

const ll INF = 1e13;

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;

    vector<ll> a(n), b(n);
    cin >> a;

    ll allowed = INF;
    vector<ll> res(n);

    res[0] = a[0];
    rep(i, 1, n) {
        res[i] = a[i] - a[i - 1];
    }

    rep(len, 1, n + 1) {
        rep(fr, 0, n - len + 1) {
            ll cur = 0;
            rep(j, fr, fr + len) {
                cur += res[j];
            }
            if (cur > a[len-1]) {
                cout << "NIE" << endl;
                return 0;
            }
        }
    }

    cout << "TAK" << endl;
    cout << res.size() << endl;
    cout << res << endl;
}