#K6996. Sum of Unique Elements

    ID: 33202 Type: Default 1000ms 256MiB

Sum of Unique Elements

Sum of Unique Elements

Problem Description

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

Formally, given an array \(arr\) of \(N\) integers, an element \(x\) is considered unique if its frequency \(f(x) = 1\). You need to calculate the sum \[ S = \sum_{x \text{ is unique}} x \] and output \(S\).

This is a simple problem that tests your ability to manipulate arrays and use frequency counts.

inputFormat

Input Format

The input is given via standard input (stdin) and consists of two parts:

  1. The first line contains a single integer \(N\) — the number of elements in the array.
  2. The second line contains \(N\) space-separated integers representing the elements of the array.

outputFormat

Output Format

Output a single integer on standard output (stdout) which is the sum of all unique elements in the array.

## sample
5
1 2 3 4 5
15