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
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <map>
#include <stdlib.h>
#include <vector>
#include <cstring>
#include <algorithm>  

using namespace std;


bool isOkCurrentCalc(vector<int> input, int currentPosition, int value) {
        int groups = currentPosition + 1;

        int wholeCount = value / groups;
        int restCount = value % groups; 
        long long int groupCounter = wholeCount;
                if (restCount != 0) {
                    if (restCount < 0) {
                        restCount++;
                        groupCounter--;
                    } else if (restCount > 0){
                        restCount--;
                        groupCounter++;
                    }

                }

        int position = 0;

        while (position < currentPosition) {
            
            if (groupCounter > input[position]) {
                return false;
            } else {
                groupCounter+=wholeCount;
                if (restCount != 0) {
                    if (restCount < 0) {
                        restCount++;
                        groupCounter--;
                    } else if (restCount > 0){
                        restCount--;
                        groupCounter++;
                    }

                }
            }
            position++;
        }
        return true;


}

int main() {
    int numbers;
	scanf("%d", &numbers);

    vector<int> input;
    input.reserve(301);

    vector<long long int> output;
    output.reserve(100301);


    for (int i = 0 ; i < numbers; i++) {
        
        int k;
        scanf("%d", &k);
        input.push_back(k);
    }

    long long int minimum = -10000000000000LL;

    long long int maxPossibleValue = 10000000000000LL;

    bool canBeCreated = true;

    for (int i = 0 ; i < input.size(); i++) {
        int groups = i + 1;
        int value = input[i];

        int wholeCount = value / groups;
        int restCount = value % groups; 
        bool resuult = isOkCurrentCalc(input, i, value);
        if (resuult == false) {
            canBeCreated = false;
            break;
        } else {
            output.push_back(minimum);
            for (int j = 0 ; j <  groups; j++) {
                long long int toDrop = wholeCount;
                if (restCount != 0) {
                    if (restCount < 0) {
                        restCount++;
                        toDrop--;
                    } else if (restCount > 0){
                        restCount--;
                        toDrop++;
                    }

                }
                output.push_back(toDrop);
            }
        }

    }

    if (canBeCreated) {
        printf("TAK\n");
        printf("%d\n", output.size());
        for(int i = 0; i < output.size(); i++){
            printf("%lld ", output[i]);
        }

    } else {
        printf("NIE");
    }
    
    return 0;
}