TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

You are given N numbers. You have to determine which one is positive and can be divisible by 396. If there are more than one, find the maximal. If several elements are maximal, find the second last one.

Input Format

The first line of each testcase
contains the integer N (1 ≤ N ≤ 100000).
Each of the following N lines contains one non-negative number. The length of any line does not exceed 30000 characters. Total size of input file doesn’t exceed 8 MB.

Output Format

For each testcase consist of exactly one line containing the desired number. Output 0 if no answer .

Sample Input 1

3
0003960
15
740916000000000000000
5
0003960
15122221
003960
3960
40916000000000000000
2
0
1

Sample Output 1

3
3
0

Hints

Problem Source

Migrated from old NTUJ.

icpc2008, neerc west

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 10000 65536 200