A foundry has n metal samples, each with an integer property value. A valid alloy uses three samples taken from three different positions whose property values add up to exactly t. Two alloys are considered the same if they use the same multiset of three values (regardless of which positions were chosen). Count the number of distinct alloys.
Input format
Line 1: an integer n.
Line 2: n space-separated integers, the property values.
Line 3: an integer t, the target sum.
Output format
A single integer: the number of distinct value-multisets {a, b, c} (formable from three different positions) with a + b + c == t.
Constraints
- 1 ≤ n ≤ 4000
- -1000000000 ≤ each value ≤ 1000000000
- -3000000000 ≤ t ≤ 3000000000