Sums and Differences
InterviewTime limit1sMemory limit128 MB
Count ordered pairs from distinct positions where the difference exceeds the sum, which holds exactly when the second element is negative.
- Level
Easy2 of 10
- Topics
- Math, Combinatorics
- Solved
- No attempts yet
Problem
You are given integers. Count how many ordered pairs satisfy , where and are two elements taken from different positions (the same position cannot be used for both and ).
Input
The first line contains an integer (). The second line contains integers () separated by spaces.
Output
Print the number of ordered pairs whose difference is greater than their sum.
Hint
When the numbers are , the possible ordered pairs are , six in total. Among them, and satisfy the condition.