According to rules of the Berland fashion, a jacket should be fastened by all the buttons except only one, but not necessarily it should be the last one. Also if the jacket has only one button, it should be fastened, so the jacket will not swinging open.

You are given a jacket with n buttons. Determine if it is fastened in a right way.


-----Input-----

The first line contains integer n (1 ≤ n ≤ 1000) — the number of buttons on the jacket.

The second line contains n integers a_{i} (0 ≤ a_{i} ≤ 1). The number a_{i} = 0 if the i-th button is not fastened. Otherwise a_{i} = 1.


-----Output-----

In the only line print the word "YES" if the jacket is fastened in a right way. Otherwise print the word "NO".


-----Examples-----
Input
3
1 0 1

Output
YES

Input
3
1 0 0

Output
NO

Difficulty: interview

Starter code:

Solutions:
n = int(input())
a = sum(list(map(int, input().split())))
if n == 1:
	if a == 1:
		print("YES")
	else:
		print("NO")
else:
	if a == n - 1:
		print("YES")
	else:
		print("NO")


import sys, math
n=int(input())
z=list(map(int,input().split()))
a=z.count(1)
if n == 1:
    if a!=1:
        print('NO')
    else:
        print('YES')
else:
    if a!=n-1:
        print('NO')
    else:
        print('YES')

n = int(input())
a = list(map(int, input().split()))
if (n == 1 and a != [1]) or (n != 1 and a.count(1) != n - 1):
    print('NO')
else:
    print('YES')


input()
a = list(map(int,input().split()))
print("YES" if (len(a)==1 and sum(a)==1) or (len(a)!=1 and sum(a)==len(a)-1) else "NO")


n = int(input())
a = list(map(int, input().split()))
print("YES" if (n == 1 and a.count(0) == 0) or (n > 1 and a.count(0) == 1) else "NO")

n = int(input())
l = list(map(int, input().split()))
if n == 1:
    if l[0] == 1:
        print("YES")
    else:
        print("NO")
elif sum(l) == n - 1:
    print("YES")
else:
    print("NO")

n = int(input())
ai = list(map(int,input().split()))
num = sum(ai)
if n == 1:
    if num == 1:
        print("YES")
    else:
        print("NO")
else:
    if n - num == 1:
        print("YES")
    else:
        print("NO")
    


n = int(input())
a = list(map(int, input().split()))
s = 0
for i in range(n):
	s += a[i]
if (s == n - 1 and n > 1 or s == 1 and n == 1):
	print("YES")
else:
	print("NO")

n = int(input())
s = sum(map(int, input().split()))
if (s == n - 1 and n > 1) or (s == 1 and n == 1):
    print("YES")
else:
    print("NO")

n = int(input())
if n == 1:
    if input() == '0':
        print('NO')
    else:
        print('YES')
else:
    sum = 0
    for s in input().split():
        if int(s) == 0:
            sum += 1
        if sum > 1:
            break
    if sum == 1:
        print('YES')
    else:
        print('NO')
        


3

a = int(input())
data = list(map(int, input().split()))

c0, c1 = 0, 0

for el in data:
    if el == 1:
        c1 += 1
    else:
        c0 += 1

if (a == 1 and c0 == 0 and c1 == 1) or (a > 1 and c0 == 1):
    print("YES")
else:
    print("NO")


l = int(input())
n = input().split()
for x in range(0, l):
    n[x] = int(n[x])
if l == 1 and (n[0] == 1):
    print("YES")
elif l-1 == sum(n) and l!=1:
    print("YES")
else:
    print("NO")

n = int(input())
a = list(map(int, input().split()))
if sum(a) >= 1 and sum(a) == max(1, n - 1):
    print("YES")
else:
    print("NO")

c = int(input())

*d, = input().split()

if d.count('1') == c == 1 or (d.count('0') == 1 and c > 1):
    print('YES')
else:
    print('NO')


n = int(input())
l = list(map(int,input().split()))
if n ==1:
    if l[0]==1: print("YES")
    else:
        print("NO")
else:
    if l.count(1) == n-1:
        print("YES")
    else:
        print("NO")

def main():
    n = int(input())
    
    b = [int(x) for x in input().split()]
    
    if len(b) == 1:
        if b[0] == 0:
            print("NO")
        else:
            print("YES")
    else:
        flag = False
    
        for x in b:
            if x == 0:
                if not flag:
                    flag = True
                else:
                    print("NO")
                    return 
        if flag:
            print("YES")
        else:
            print("NO")
    
main()


n = int(input())
a = [int(ai) for ai in input().split()]


if (len(a)==1 and a[0]==1) or (len(list(ai for ai in a if ai==0))==1 and len(a)>1):
	print("YES")
else: print("NO")


k='AHIMOTUVWXY'
l='iuvwo'
x = int(input())
y = list(map(int, input().split(' ')))
if (y.count(1) == x-1 or y == [1]) and y != [0]:
    print("YES")
else:
    print("NO")


n, a = int(input()), input().split()

if n == 1:
    if a[0] == '1':
        print('YES')
    else:
        print('NO')
else:
    unfst = len([x for x in a if x == '0'])
    if unfst == 1:
        print('YES')
    else:
        print('NO')


n = int(input())
a = sum(map(int, input().split(' ')))
if n == 1:
    if a == 1:
        print('YES')
    else:
        print('NO')
else:
    if a == n - 1:
        print('YES')
    else:
        print('NO')


n=int(input())
s=input().split()
t=False
if n==1:
    if s[0]=='0':
        print('NO')
        return
    else:
        print('YES')
        return
else:
    for i in range(n):
        if s[i]=='0':
            if t:
                print('NO')
                return
            else:
                t=True
if not t:
    print('NO')
else:
    print('YES')


n = int(input())

a = list(map(int, input().split()))

if len(a) == 1:
    if a[0] == 1:
        print('YES')
    else:
        print('NO')
else:
    zeros = a.count(0)
    if zeros == 1:
        print('YES')
    else:
        print('NO')


n = int(input())
nums = list(map(int, input().split()))

if n == 1:
  if nums[0] == 1:
    print("YES")
  else:
    print("NO")
else:
  if nums.count(1) == n-1:
    print("YES")
  else:
    print("NO")


# You lost the game.
n = int(input())
L = list(map(int, input().split()))
if (n > 1 and sum(L) == n-1) or (n == 1 and sum(L) == n):
    print("YES")
else:
    print("NO")