An analyst reviews n asset returns, each an integer. A portfolio picks four assets from four different positions whose returns add up to exactly t. Two portfolios are the same if they use the same multiset of four return values (regardless of which positions). Count the number of distinct portfolios.
Input format
Line 1: an integer n.
Line 2: n space-separated integers, the asset returns.
Line 3: an integer t, the target sum.
Output format
A single integer: the number of distinct value-multisets {a, b, c, d} (formable from four different positions) with a + b + c + d == t.
Constraints
- 1 ≤ n ≤ 500
- -1000000000 ≤ each return ≤ 1000000000
- -4000000000 ≤ t ≤ 4000000000