Problem:
Score: 200 points

Problem Statement

You are an immigration officer in the Kingdom of AtCoder. The document carried by an immigrant has some number of integers written on it, and you need to check whether they meet certain criteria.

According to the regulation, the immigrant should be allowed entry to the kingdom if and only if the following condition is satisfied:

All even numbers written on the document are divisible by 3 or 5.

If the immigrant should be allowed entry according to the regulation, output APPROVED; otherwise, print DENIED.

Notes

The condition in the statement can be rephrased as "If x is an even number written on the document, x is divisible by 3 or 5".
Here "if" and "or" are logical terms.

Constraints

All values in input are integers.

1 \leq N \leq 100

1 \leq A_i \leq 1000

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 \dots A_N

Output

If the immigrant should be allowed entry according to the regulation, print APPROVED; otherwise, print DENIED.

Sample Input 1

5
6 7 9 10 31

Sample Output 1

APPROVED

The even numbers written on the document are 6 and 10.

All of them are divisible by 3 or 5, so the immigrant should be allowed entry.

Sample Input 2

3
28 27 24

Sample Output 2

DENIED

28 violates the condition, so the immigrant should not be allowed entry.

Solution in C# (Mono 4.6.2.0) (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;

public class ABC155_B
{

    public static void Main()
    {
        int c = 0;
        InLine(ref c);
        string s = "";
        InLine(ref s);
        int[] ints = s.Split(' ').Select(int.Parse).ToArray();
        foreach (int i in ints)
        {
            if (!IsDivisible(i, 2)) continue;
            else if (IsDivisible(i, 3) || IsDivisible(i, 5)) continue;
            else
            {
                Out("DENIED");
                return;
            }
        }
        Out("APPROVED");
    }

    //Template
    private static object[] nullobjs = null;
    private static object nullobj = null;

    public static int ConvertInt(char c)
    {
        return c;
    }

    public static void InArgs<A>(int count, ref A[] var)
    {
        InArgs(count, ref var, ref nullobjs, ref nullobjs);
    }

    public static void InArgs<A, B>(int count, ref A[] var1, ref B[] var2)
    {
        InArgs(count, ref var1, ref var2, ref nullobjs);
    }

    public static void InArgs<A, B, C>(int count, ref A[] var1, ref B[] var2, ref C[] var3)
    {
        A a = default(A);
        B b = default(B);
        C c = default(C);
        for (int i = 0; i < count; i++)
        {
            InLine(ref a, ref b, ref c);
            var1[i] = a;
            if (var2 != null) var2[i] = b;
            if (var3 != null) var3[i] = c;
        }
    }

    public static void InLine<A>(ref A var)
    {
        InLine(ref var, ref nullobj, ref nullobj);
    }

    public static void InLine<A, B>(ref A var1, ref B var2)
    {
        InLine(ref var1, ref var2, ref nullobj);
    }

    public static void InLine<A, B, C>(ref A var1, ref B var2, ref C var3)
    {
        object[] o = new object[] { var1, var2, var3 };
        Type[] t = new Type[] { typeof(A), typeof(B), typeof(C) };
        if (var3 == null)
        {
            if (var2 == null) o = new object[] { var1 };
            else o = new object[] { var1, var2 };
        }

        var line = Console.ReadLine();
        string[] s = null;
        if (o.Length == 1) s = new string[1] { line };
        else line.Split(' ');
        for (int i = 0; i < s.Length; i++)
        {
            if (typeof(int) == t[i]) o[i] = int.Parse(s[i]);
            else if (typeof(long) == t[i]) o[i] = long.Parse(s[i]);
            else if (typeof(double) == t[i]) o[i] = double.Parse(s[i]);
            else o[i] = s[i];
        }
        var1 = (A)o[0];
        if (var2 != null) var2 = (B)o[1];
        if (var3 != null) var3 = (C)o[2];
    }

    public static string JoinString(object[] obj, string sep)
    {
        return string.Join(sep, obj.Select(i => i.ToString()).ToArray());
    }

    public static void Out(object o)
    {
        Console.WriteLine(o);
    }

    public static void OutYes()
    {
        Console.WriteLine("Yes");
    }

    public static void OutNo()
    {
        Console.WriteLine("No");
    }
    public static void OutYES()
    {
        Console.WriteLine("YES");
    }

    public static void OutNO()
    {
        Console.WriteLine("NO");
    }

    private static Dictionary<A, B> PutDict<A, B>(A[] key, B[] value)
    {
        if (key.Length != value.Length) return null;
        var dic = new Dictionary<A, B>();
        for (int i = 0; i < key.Length; i++)
        {
            if (!dic.ContainsKey(key[i])) dic.Add(key[i], value[i]);
            else dic[key[i]] = value[i];
        }
        return dic;
    }

    public static int[] CommonDivisor(int num)
    {
        return CommonDivisor((long)num).Select(i => (int)i).ToArray();
    }

    public static long[] CommonDivisor(long num)
    {
        long l = 2, n = num;
        long[] result = new long[0];

        while (l * l <= num)
        {
            if (n % l == 0)
            {
                n /= l;
                Array.Resize(ref result, result.Length + 1);
                result[result.Length - 1] = l;
            }
            else l++;
        }
        if (n != 1)
        {
            Array.Resize(ref result, result.Length + 1);
            result[result.Length - 1] = n;
        }
        return result;
    }

    public static bool Compare(bool equal, long a, long x)
    {
        return Compare(equal, a, x, long.MaxValue, true);
    }

    public static bool Compare(long x, long b, bool equal)
    {
        return Compare(true, long.MinValue, x, b, equal);
    }

    public static bool Compare(bool lequal, long a, long x, long b, bool requal)
    {
        if (a <= x && x <= b)
        {
            if (!lequal && x == a) return false;
            else if (!requal && x == b) return false;
            else return true;
        }
        return false;
    }

    //割り切る
    public static bool IsDivisible(long a, long b)
    {
        return a % b == 0;
    }

    //互いに素
    public static bool IsRelativelyPrime(long a, long b)
    {
        bool result = false;
        if (a > 1 && b > 1)
            result = CommonDivisor(a).Intersect(CommonDivisor(b)).ToArray().Length == 0;
        return result;
    }

    //素数判定
    public static bool IsPrimeNumber(int num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false;

        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2)
        {
            if (num % i == 0) return false;
        }
        return true;
    }

    //階乗
    public static long Factorial(long num)
    {
        long result = 1;
        for (long l = 0; l < num; l++)
            result *= l + 1;
        return result;
    }

    //最大公約数
    public static int GCD(int a, int b)
    {
        return (int)GCD((long)a, b);
    }

    public static long GCD(long a, long b)
    {
        long[] acd = CommonDivisor(a).ToArray(), bcd = CommonDivisor(b).ToArray();
        Dictionary<long, int> dic1 = new Dictionary<long, int>(), dic2 = new Dictionary<long, int>();
        int count = 0;
        long n = 0, result = 1;
        for (int i = 0; i < acd.Length; i++)
        {
            if (n == acd[i]) count++;
            else
            {
                if (n != 0) dic1.Add(n, count);
                n = acd[i];
                count = 1;
            }
        }
        dic1.Add(n, count);
        n = 0;
        count = 0;
        for (int i = 0; i < bcd.Length; i++)
        {
            if (n == bcd[i]) count++;
            else
            {
                if (dic1.ContainsKey(n)) dic2[n] = Math.Max(count, dic1[n]);
                n = bcd[i];
                count = 1;
            }
        }
        if (dic1.ContainsKey(n)) dic2[n] = Math.Max(count, dic1[n]);
        foreach (long l in dic2.Keys)
        {
            result *= (long)Math.Pow(l, dic2[l]);
            Console.WriteLine($"{l}, {dic2[l]}");
        }
        return result;
    }

    //最小公倍数

    public static long LCM(long a, long b)
    {
        long[] acd = CommonDivisor(a).ToArray(), bcd = CommonDivisor(b).ToArray();
        var dic = new Dictionary<long, int>();
        int count = 0;
        long n = 0, result = 1;
        for (int i = 0; i < acd.Length; i++)
        {
            if (n == acd[i]) count++;
            else
            {
                if (n != 0) dic.Add(n, count);
                n = acd[i];
                count = 1;
            }
        }
        dic.Add(n, count);
        n = 0;
        count = 0;
        for (int i = 0; i < bcd.Length; i++)
        {
            if (n == bcd[i]) count++;
            else
            {
                if (dic.ContainsKey(n)) dic[n] = Math.Max(count, dic[n]);
                else if (n != 0) dic.Add(n, count);
                n = bcd[i];
                count = 1;
            }
        }
        if (dic.ContainsKey(n)) dic[n] = Math.Max(count, dic[n]);
        else dic.Add(n, count);
        foreach (long l in dic.Keys)
            result *= (long)Math.Pow(l, dic[l]);
        return result;
    }

    public static long TotalMultiply(long[] ls)
    {
        long result = 1;
        foreach (long l in ls)
            result *= l;
        return result;
    }
}