#C1465. Sum of Unique Elements

    ID: 44322 Type: Default 1000ms 256MiB

Sum of Unique Elements

Sum of Unique Elements

You are given an array of integers. Your task is to compute the sum of all unique elements in the array, where a unique element is defined as an element that appears exactly once.

In mathematical terms, if the array is \( A = [a_1, a_2, \dots, a_n] \), then you need to find:

[ S = \sum_{\substack{a \in A \ \text{frequency}(a)=1}} a ]

For example, consider the array [1, 2, 3, 2, 4, 1]. The number 3 and 4 appear exactly once, so the answer would be 3 + 4 = 7.

inputFormat

The first line of the input contains a single integer n, representing the number of elements in the array. The second line contains n space-separated integers.

outputFormat

Output a single integer — the sum of all unique elements in the array.## sample

6
1 2 3 2 4 1
7