#t88. 好事成双
好事成双
A Pair of Good Things
Problem Description
Dazhi's father has finished his engineering project smoothly, and his mother has been promoted to manager — truly a pair of good things. To celebrate, Dazhi's father wants to set Dazhi a problem (poor Dazhi). We now define a "good-thing pair": for two numbers , if or holds, then and are said to be a "good-thing pair". Given an array, count how many good-thing pairs it contains.
Input Format
A sequence of positive integers, each not exceeding and all distinct, ending with the number to mark the end of input.
Output Format
Output one integer as the answer.
Sample Input
1 4 3 2 9 7 18 22 0
Sample Output
3
Hint
1 4 3 2 9 7 18 22 0
There are pairs in total: and , and , and .