Check if possible to make Array sum equal to Array product by replacing exactly one element | Function to check if it is possible to form an array whose sum and the product is the same or not ; Find the sum of the array ;  ; Find the product of the array ; Check a complete integer y for every x ; If got such y ; If no such y exist ; Driver Code
def canPossibleReplacement ( N , arr ) : NEW_LINE INDENT S = sum ( arr ) NEW_LINE DEDENT / * Iterate through all elements and NEW_LINE INDENT add them to sum * / NEW_LINE P = 1 NEW_LINE for i in arr : NEW_LINE INDENT P *= i NEW_LINE DEDENT for x in arr : NEW_LINE INDENT y = ( S - x ) // ( P / x - 1 ) NEW_LINE if ( S - x + y ) == ( P * y ) / x : NEW_LINE INDENT return ' Yes ' NEW_LINE DEDENT DEDENT return ' No ' NEW_LINE DEDENT N , arr = 3 , [ 1 , 3 , 4 ] NEW_LINE print ( canPossibleReplacement ( N , arr ) ) NEW_LINE