// Arup Guha
// 4/12/2012
// Solution to 2003 South East Regional Problem: Collide

#include <stdio.h>

long long lcm(long long a, long long b);
long long gcd(long long a, long long b);
long long gcd2(long long a, long long b);

int main() {

    // Open the input file.
    FILE* ifp = fopen("collide.in", "r");

    int numPlanets, list = 1;
    fscanf(ifp, "%d", &numPlanets);

    // Process each case.
    while (numPlanets > 0) {

        long long period = 1;

        int i;

        // Add in each planet to the calculation.
        for (i=0; i<numPlanets; i++) {

            long long newplanet;
            fscanf(ifp, "%d", &newplanet);

            // Detects periods that are too long.
            if (period == -1) continue;

            // Recalculate the new period with this planet.
            period = lcm(period, newplanet);

            // Our period is too long.
            if (period > 2147483647.1) {
                period = -1;
            }
        }

        // Output the results.
        if (period != -1)
            printf("%d: THE WORLD ENDS IN %d DAYS\n", list, period );
        else
            printf("%d: NOT TO WORRY\n", list);

        fscanf(ifp, "%d", &numPlanets);
        list++;
    }

    fclose(ifp);
    return 0;

}

// Calculates the least common multiple of a and b.
long long lcm(long long a, long long b) {
    return a/gcd2(a,b)*b;
}

// Recursively calculates the greatest common divisor of a and b.
long long gcd(long long a, long long b) {

    if (a == 0) return b;
    if (b == 0) return a;
    return gcd(b, a%b);
}

// Calculates the greatest common divisor using the algorithm
// shown in COT 3100.
long long gcd2(long long a, long long b) {

    // Calculate our first remainder.
    long long r = a%b;

    // Continue iterating until we get a 0 remainder.
    while (r != 0) {
        a = b;
        b = r;
        r = a%b;
    }

    // This is our GCD.
    return b;
}
