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

int a[512], b[512], pref[512];

int main()
{
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
  {
    scanf("%d", a + i);
  }

  pref[0] = 0;
  pref[1] = a[1];
  b[1] = a[1];
  
  for (int i = 2; i <= n; i++)
  {
    b[i] = a[i] - a[i - 1];
    pref[i] = pref[i - 1] + b[i];
  }
  
  bool ok = true;
  
  for (int k = 0; k < n; k++)
  {
    for (int i = 1; i + k <= n; i++)
    {
      int s = pref[i + k] - pref[i - 1];
      if (s > a[k + 1]) ok = false;
    }
  }
  if (ok)
  {
    printf("TAK\n");
    printf("%d\n", n);
    for (int i = 1; i <= n; i++)
    {
      printf("%d ", b[i]);
    }
  }
  else
  {
    printf("NIE");
  }
  
  
  return 0;
}