Find Good Reverse Tuple

时间限制: 1000 ms 内存限制: 65536 kb
总通过人数: 0 总提交人数: 0

Time limit 1s, space limit 256MB

Description

Suppose we have a function revNum(num), which can reverse the digits of num. For example, revNum(789) = 987 and revNum(10) = 1.

Now given a list of non-negative integers nums, consider a tuple of indices (i, j, k), where i < j < k, we say the tuple is Good Reverse Tuple if it satisfies nums[i] + nums[j] + nums[k] = revNum(nums[i]) + revNum(nums[j]) + revNum(nums[k]).

Please return the number of Good Reverse Tuple.

Input

The fine line is a number n (3 <= n <= 1000), means the length of the sequence. The second line contains a sequence of n integers. Each integer is in the range [0, 1000].

Output

Print the number of Good Reverse Tuple.

Sample Input 1

4
21 17 5 23

Sample Output 1

1

Sample Input 2:

3
3 24 15

Sample Output 2:

0

相关推荐