# Function to calculate power def pow(a: int, b: int): ret = 1 for i in range(b): ret *= a return ret # Main Function def main(): # Read number of elements n = int(input()) # Read array elements a = list(map(int, input().split())) # Array to count frequencyc of each numbers counter = [0 for i in range(9)] for v in a: counter[v] += 1 # Variable to store answer ans = 0 for b in range(1, 9): for e in range(1, 9): ans += counter[b] * counter[e] * pow(b, e) # Print ans print(ans) if __name__ == "__main__": main()