Problem

23 /23


Maximum amount of an arbitrary pair

Problem

The input of the program is a sequence of N non-negative integers. All pairs of different elements of the sequence are considered (the elements of a pair do not have to be side by side in the sequence, the order of the elements in the pair is not important). Find the maximum sum of an arbitrary pair of non-zero elements of a sequence. The found sum must be a multiple of three and there must be zero elements between the elements of the pair. If there is no such pair, print 0.


Input
The first line of the input specifies the number of numbers N (\(1 < N <= 10000\)). Each of the following N lines contains one non-negative integer not exceeding 10000.

Input
As a result, the program should output a single number, the number of pairs found.
 
Examples
# Input Output
1 7
1
0
2
0
5
0
8
9