Problem

22 /23


Based on the Unified State Examination 2020

Problem

Given a sequence N of positive integers not exceeding 10000. We consider all pairs of elements of the sequence that have different remainders after division by \(D=140\) and at least one of the numbers is divisible by \(C=7\). Among all such pairs, you need to find and output the pair with the maximum sum of elements. If several pairs have the same maximum amount, you can withdraw any of them. If there are no matching pairs in the sequence, print two zeros. .

Input
The first line contains a natural number N (\(2 <= N <= 10000\)) – the number of numbers in the sequence. The following N lines contain the numbers in the sequence, one per line.

Imprint
The program should display a pair with the maximum sum that satisfies the condition of the problem, or two zeros if there are no such pairs.
 

 

Examples
# Input Output
1
13 
14 
15 
16 
17
14 17