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
#include<cstdio>

int n;
int * t;
long long * sol;
int N;

void input() {
  scanf("%d", &n);
  t = new int[n];
  for (int i = 0; i < n; ++i) {
    scanf("%d", t + i);
  }
}

void generate() {
  N = (n * (n + 1)) / 2 + n - 1;
  sol = new long long[N];
  int s = 0;
  for (int i = 0; i < n; ++i) {
    int m = i + 1;
    int k = t[i] / m;
    if (t[i] < 0) {
      --k;
    }
    int r = ((t[i] % m) + m) % m;
    // printf("\n%d %d %d\n", m, k, r);
    for (int j = 0; j < m; ++j) {
      if (j < i - r + 1) {
        sol[s] = k;
      } else {
        sol[s] = k + 1;
      }
      ++s;
    }
    if (i < n - 1) {
      sol[s] = -10000000000000ll;
      ++s;
    }
  }
}

void print(long long * T) {
  printf("TAK\n%d\n", N);
  for (int i = 0; i < N; i++) {
    printf("%lld ", T[i]);
  }
  printf("\n");
}

long long * v;

bool valid() {
  v = new long long[N];
  for (int i = 0; i < N; i++) {
    v[i] = sol[i];
  }
  for (int i = 0; i < n; i++) {
    // printf("i = %d, t[i] = %d\n", i, t[i]);
    // print(v);
    for (int j = i + 1; j < N; j++) {
      if (v[j] > t[i]) {
        return false;
      }
      v[j] += sol[j - i - 1];
    }
  }
  return true;
}

int main() {
  input();
  generate();
  if (valid()) {
    print(sol);
  } else {
    printf("NIE\n");
  }
  // printf("-1/2=%d\n", -1/2);
  // printf("-7/2=%d\n", -7/2);
}