Recently Vasya found a golden ticket — a sequence which consists of $n$ digits $a_1a_2\dots a_n$. Vasya considers a ticket to be lucky if it can be divided into two or more non-intersecting segments with equal sums. For example, ticket $350178$ is lucky since it can be divided into three segments $350$, $17$ and $8$: $3+5+0=1+7=8$. Note that each digit of sequence should belong to exactly one segment.

Help Vasya! Tell him if the golden ticket he found is lucky or not.


-----Input-----

The first line contains one integer $n$ ($2 \le n \le 100$) — the number of digits in the ticket.

The second line contains $n$ digits $a_1 a_2 \dots a_n$ ($0 \le a_i \le 9$) — the golden ticket. Digits are printed without spaces.


-----Output-----

If the golden ticket is lucky then print "YES", otherwise print "NO" (both case insensitive).


-----Examples-----
Input
5
73452

Output
YES

Input
4
1248

Output
NO



-----Note-----

In the first example the ticket can be divided into $7$, $34$ and $52$: $7=3+4=5+2$.

In the second example it is impossible to divide ticket into segments with equal sum.

Difficulty: interview

Starter code:

Solutions:
n = int(input())
a = list(map(int, list(input())))
for i in range(n - 1):
    sm = sum(a[:i + 1])
    tn = 0
    res = True
    has = False
    for j in range(i + 1, n):
        tn += a[j]
        if (tn == sm):
            tn = 0
            has = True
        elif tn > sm:
            res = False
            break
    if (tn == 0 and res and has):
        print("YES")
        break
else:
    print("NO")

n = int(input())
s = input()
a = []
for i in range(n):
    a.append(int(s[i]))
s = sum(a)
ans = "NO"
for i in range(2, 1001):
    if (s % i != 0):
        continue
    su = s // i
    pos = 0
    ans = "YES"
    for ii in range(i):
        cur = 0
        while (pos < n and cur + a[pos] <= su):
            cur += a[pos]
            pos += 1
        if (cur != su):
            ans = "NO"
    if (ans == "YES"):
        break
print(ans)

n = int(input())
a = list(map(int, input().rstrip()))
sm = sum(a)
ans = False
for cnt in range(2, n + 1):
    if sm % cnt != 0:
        continue
    seq_sum = sm // cnt
    cur_sum = 0
    ans = True
    for i in range(n):
        cur_sum += a[i]
        if cur_sum == seq_sum:
            cur_sum = 0
        if cur_sum > seq_sum:
            ans = False
            break
    if ans:
        break
print("YES" if ans else "NO")


n = int(input())
s = input()
arr = list()
arr.append(int(s[0]))
summ = arr[0]
bigflg = False
for i in range(1,len(s)):
    arr.append(int(s[i]))
    summ+=arr[i]
for i in range(2,len(s)+1):
    if summ % i == 0:
        amount = summ / i
        sm = 0
        flg = True
        for j in range(len(arr)):
            sm += arr[j]
            if (sm > amount):
                flg = False
                break
            if (sm == amount):
                sm = 0
        if sm==0 and flg:
            bigflg = True
            print('YES')
            break
if not bigflg:
    print('NO')


n = int(input())
a = input()
ans = 0
needs = 0
for i in range(n):
    needs += int(a[i])
    currs = 0
    for j in range(i + 1, n):
        currs += int(a[j])
        if currs > needs:
            break
        elif currs == needs:
            if j == n - 1:
                ans = 1
                break
            else:
                if a[j + 1] != '0':
                    currs = 0
if ans:
    print('YES')
else:
    print('NO')

import sys
n = int(input())
arr = list(map(int, list(input())))
if n > 1 and sum(arr) == 0:
    print("YES")
    return
arr = [el for el in arr if el != 0]
n = len(arr)
for i in range(1, sum(arr)):
    cur = 0
    cur_sum = 0
    while True:
        while cur < n and cur_sum < i:
            cur_sum += arr[cur]
            cur += 1
        if cur_sum == i:
            cur_sum = 0
        elif cur_sum != i:
            break
        if cur == n:
            print("YES")
            return
print("NO")


n = int(input())
s = input()
for i in range(901):
	j = 0
	summa = 0
	f = True
	q = 0
	while j < n and f:
		summa += int(s[j])
		if summa > i:
			f = False
		elif summa == i:
			q += 1
			summa = 0
		j += 1
	if summa == 0 and f and q > 1:
		print("YES")
		return
print("NO")
		


def check(a, count):
    ks = 0
    for i in range(len(a)):
        ks += a[i]
        if ks > count:
            return False
        elif ks == count:
            ks = 0

    return True
    


n = int(input())
a = list(map(int, list(input())))
ss = sum(a)
flag = False
for k in range(2, 1000):
    if ss % k == 0:
        if check(a, ss // k):
            flag = True
            break
if flag:
    print('YES')
else:
    print('NO')

def check(i):
    s = 0
    for x in b:
        s += x
        if s == i:
            s = 0
    if s == 0:
        return True
    return False
a = int(input())
b = [int(i) for i in list(input())]
for i in range(max(1, sum(b))):
    if check(i):
        print("YES")
        break
else:
    print("NO")

n = int(input())
s = input()
a = [int(i) for i in s]
m = sum(a)
for i in range(2, n + 1):
    if m % i == 0:
        k = m // i
        summ = 0
        cnt = 0
        for i in range(n):
            summ += a[i]
            if summ == k:
                cnt += 1
                summ = 0
        if k * cnt == m:
            print("YES")
            return
print("NO")


n = int(input())
s = input()
arr = []
sum = 0
for i in s:
    arr.append(int(i))
    sum += (int(i))
ok = False
if (sum > 0):
    for i in range(2, sum + 1):
        if (sum % i == 0):
            sums = 0
            ok = True
            for j in range(n):
                sums += arr[j]
                if (sums == sum / i):
                    sums = 0
                elif (sums > sum / i):
                    ok = False
                    break
        if ok:
            break
else:
    ok = True
if ok:
    print("YES")
else:
    print("NO")

n = int(input())

s = input()

maxi = -1

for x in range(901):
    f = False
    acc = 0
    cnt = 0
    for y in range(n):
        if acc + int(s[y]) > x:
            f = True
            break
        elif acc + int(s[y]) == x:
            acc = 0
            cnt += 1
        else:
            acc += int(s[y])
    if f:
        continue
    elif acc == 0 and cnt >= 2:
        maxi = x

if maxi == -1:
    print("NO")
else:
    print("YES")


n=int(input())
s=input()
su=0
for i in s:
    su+=int(i)
tr=0
if (su==0):
    print("YES")
else:
    for i in range(1,su):
        if (su%i==0):
            t=0
            x=1
            for c in s:
                if (t+int(c)== i):
                    t=0
                elif(t+int(c)>i):
                    x=0
                else:
                    t+=int(c)
            if(x==1):
                tr=1
    if (tr==1):
        print("YES")
    else:
        print("NO")


n = int(input())
s = input()
sm = (sum(map(int, list(s))))
dv = 2
ans = []
while dv <= n:
    if sm % dv == 0:
        summ = 0
        tmp = True
        for i in range(len(s)):
            summ += int(s[i])
            if summ == sm // dv:
                summ = 0
            elif summ > sm // dv:
                tmp = False
        if tmp:
            ans.append(dv)
    dv += 1
if ans:
    print('YES')
else:
    print('NO')

n = int(input())
a = [int(c) for c in input()]
while a and a[-1] == 0:
    a.pop()
n = len(a)
acc = [0] * (n + 1)
for i in range(1, n + 1):
    acc[i] = acc[i - 1] + a[i - 1]
res = n == 0
for l in range(1, n):
    pos = l
    res2 = True
    while pos < n and res2:
        for i in range(pos + 1, n + 1):
            if acc[i] - acc[pos] == acc[l]:
                pos = i
                break
            if acc[i] - acc[pos] > acc[l] or i == n:
                res2 = False
                break
    if res2:
        res = True
        break

print("YES" if res else "NO")

import sys


n = int(input())
array = list(input())
for i in range(n):
    array[i] = int(array[i])
for i in range(sum(array) + 1):
    if sum(array) == 0 or (i != 0 and sum(array) % i == 0 and i < sum(array)):
        k = 0
        l = 0
        for j in array:
            k = k + j
            if k == i:
                k = 0
                l += 1
            elif k > i:
                break
        if k == 0 and l > 1:
            print("YES")
            return
print("NO")


def sum_o(s):
    if s == '':
        return 0
    res = 0
    for el in s:
        res += int(el)
    return res
def can(s, summ):# 3452 7
    if sum_o(s) == summ:
        return True
    res = ''
    for i in range(len(s)):
        wl = s[i]
        res += wl
        if sum_o(res) == summ:
            if can(s[i+1:], summ):
                return True
            else:
                return False
        if sum_o(res) > summ:
            return False
def main():
    n = int(input())
    s = input()
    for i in range(1,n):
        if can(s[i:], sum_o(s[:i])):
            return 'YES'
    return 'NO'
print(main())


n = int(input())
a = list(input())

for i in range(len(a)):
    a[i] = int(a[i])
s = sum(a)

for i in range(2, n+1):
    if s % i == 0:
        b = s // i

        t_sum = 0
        t_k = 0
        for k in a:
            if t_k > i:
                break
            t_sum += k
            if t_sum < b:
                continue
            elif t_sum == b:
                t_sum = 0
                t_k += 1
                continue
            else:
                break
        if t_k == i:
            print("YES")
            return

print("NO")
          
        


a=int(input())
b=[int(x) for x in input()]
c=sum(b)
e=[]
for i in range(2,len(b)+1):
    if c%i==0:
        e.append(i)
d=False
for i in e:
    r=[]
    b1=b[:]
    num=c//i
    k=0
    while b1:
        k+=b1[0]
        b1=b1[1:]
        if k==num:
            r.append(k)
            k=0
        elif k>num:
            break
        if len(r)==i:
            d=True   
if d:
    print('YES')
else:
    print('NO')


n = int(input())
pre_res = 1
max_s = n * 9
s = input()
sums = [1]*(max_s+1)
i = 1
while i <= max_s:
	sums[i] = i
	i += 1
for c in s:
	if c != '0':
		d = int(c)
		i = 1
		while i <= max_s:
			if sums[i] == i:
				sums[i] = d
			else:
				sums[i] += d
			i += 1
res = 1
i = 1
while i <= max_s:
	if sums[i] == i:
		res += 1
	i += 1
if res == 2:
	print("NO")
else:
	print("YES")


n = int(input())
s = input()
summ = 0
for i in range(n):
    summ += int(s[i])
for i in range(2, 101):
    if summ % i == 0:
        d = 0
        for j in range(n):
            d += int(s[j])
            if d * i == summ:
                d = 0
            if d * i > summ:
                break
        if (j == n - 1 and d == 0):
            print('YES')
            return
print('NO')
            


import sys

input()
s = input()
maxc = len(s) // 2 * 9
for i in range(0, maxc):
    sum = 0
    r = "Y"
    l = 0
    for c in range(len(s)):
        sum += int(s[c])
        if sum == i:
            sum = 0
            l += 1
        elif sum > i:
            r = "N"
            break
    if r == "Y" and sum == 0 and l > 1:
        print("YES")
        return

print("NO")


n = int(input())
t = list(map(int, input()))
a = []
for i in t:
  if i != 0:
    a.append(i)
if a == []:
  print('YES')
  return

for i in range(1, len(a)):
  sumn = sum(a[:i])
  snow = 0
  for j in range(i, len(a)):
    snow += a[j]
    if j == len(a) - 1 and snow == sumn:
      print('YES')
      return
    elif snow == sumn:
      snow = 0
    elif snow > sumn:
      break

print('NO')

def test(x):
    nonlocal arr, n
    s = 0
    for i in range(n):
        s += arr[i]
        if s > x:
            return False
        elif s == x:
            s = 0
    return s == 0



n = int(input())
oarr = list(map(int, list(input())))
arr = []
for el in oarr:
    if el:
        arr.append(el)
    else:
        n -= 1
s = 0
for i in range(n - 1):
    s += arr[i]
    if test(s):
        print("YES")
        break
else:
    if n == 0:
        print("YES")
    else:
        print("NO")