Sum of all ordered pair | Function to calculate the sum of all pair - products ; Stores sum of array ; Update sum of the array ; Driver Code
def sumOfProd ( arr , N ) : NEW_LINE INDENT sum = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT sum += arr [ i ] NEW_LINE DEDENT return sum * sum NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 2 , 3 , 1 , 5 , 4 ] NEW_LINE N = len ( arr ) NEW_LINE print ( sumOfProd ( arr , N ) ) NEW_LINE DEDENT