Sum of product of all pairs
Submissions: 900   Accuracy:

60.24%

  Difficulty: Easy   Marks: 2

Given an array A[] of integers find sum of product of all pairs of array elements.

Input:
First line consists of T test cases. First line of every test case consists of N, denoting number of elements of array. Second line consists of elements of array.

Output:
Single line output, print the sum of products.

Constraints:
1<=T<=100
1<=N<=100

Example:
Input:

1
3
1 3 4
Output:
19

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Saksham Raj Seth
Author: saksham seth


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.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.