#K37737. Subset Sum Zero

    ID: 26043 Type: Default 1000ms 256MiB

Subset Sum Zero

Subset Sum Zero

Given a set of n integers, determine whether there exists a non-empty subset whose sum is zero. Formally, for a given set \( S = \{a_1, a_2, \dots, a_n\} \), you need to decide if there is a subset \( S' \subseteq S \) with \( S' \neq \varnothing \) such that \( \sum_{x \in S'} x = 0 \). If such a subset exists, output YES; otherwise, output NO.

The subset can consist of a single element as well. All possible non-empty subsets must be considered in order to determine the correct answer. This problem can be solved using a brute-force approach due to the typically small input size.

inputFormat

The first line contains an integer n which represents the number of elements in the set. The second line contains n space-separated integers representing the elements of the set.

outputFormat

Output YES if there exists a non-empty subset whose sum equals zero; otherwise, output NO.

## sample
5
-3 1 2 -1 4
YES