Given an array of distinct integers. The task is to count all the triplets such that sum of two elements equals the third element.
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consists of two lines. First line of each test case contains an Integer N denoting size of array and the second line contains N space separated elements.
For each test case, print the count of all triplets, in new line. If no such triplets can form, print "-1".
1 <= T <= 100
3 <= N <= 105
1 <= A[i] <= 106
1 5 3 2
3 2 7
Testcase 1: There are 2 triplets: 1 + 2 = 3 and 3 +2 = 5
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.