After Mirko's failed stint as a coach and a passing obsession with Croatian meat delicacies, his weight problems have motivated him to work hard as a farmer. He has moved to a village where his friend Slavko lives. Farmers in the village share a large common plot of land in the shape of an
Slavko is skeptical of Mirko since his failure as a coach, so he insists that both of them are assigned land with the same total income, but also that the two plots share exactly one common corner so that the two friends can keep an eye on each other (Slavko knows that Mirko is prone to mischief). The common corner must be the only point where the two plots meet, in order to prevent border-related arguments.
You are given a description of the common land plot. Find the total number of plot pairs that satisfy Slavko's criteria.
Input Specification
The first line of input contains the positive integer
Each of the following
Output Specification
The first and only line of output must contain the total number of plot pairs satisfying the given condition.
Scoring
In test data worth at least 40% of total points,
Sample Input 1
3
1 2 3
2 3 4
3 4 8
Sample Output 1
7
Explanation
The possible rectangle pairs are:
and , and , and , and , and , and , and .
Sample Input 2
4
-1 -1 -1 -1
1 2 3 4
1 2 3 4
1 2 3 4
Sample Output 2
10
Sample Input 3
5
-1 -1 -1 -1 -1
-2 -2 -2 -2 -2
-3 -3 -3 -3 -3
-4 -4 -4 -4 -4
-5 -5 -5 -5 -5
Sample Output 3
36
Comments