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: EASY
Tags: Implementation

Starter code:

Solutions:
n = int(input())
a = list(map(int, input().split()))
if len(a) > 1 and sum(a) == n - 1 or (len(a) == 1 and a[0] == 1):
	print('YES')
else:
	print('NO')


n = int(input())
sum = 0
p = input().split()
for i in range(0, n):
	q = int(p[i])
	sum += q
if n == 1 and sum == 1 or (n != 1 and n == sum + 1):
	print('YES')
else:
	print('NO')


a = int(input())
x = list(map(int, input().split()))
if a == 1 and x[0] == 1:
	print('YES')
elif x.count(0) == 1 and a > 1:
	print('YES')
else:
	print('NO')


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


n = int(input())
l = list(map(int, input().split()))
if sum(l) == 1 and n == 1:
	print('YES')
elif sum(l) == n - 1 and n != 1:
	print('YES')
else:
	print('NO')


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')


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 = int(input())
a = [int(i) for i in input().split()]
if a.count(0) == 1 and n != 1:
	print('YES')
elif a.count(1) == 1 and n == 1:
	print('YES')
else:
	print('NO')


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


buttons = int(input())
order = [int(x) for x in input().split()]

def test():
	if buttons == 1:
		return order.count(1) == 1
	else:
		return order.count(0) == 1
if test():
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
if s.count('0') == 1 and len(s) != 1 or (s.count('0') == 0 and len(s) == 1):
	print('YES')
else:
	print('NO')


n = int(input())
A = list(map(int, input().split()))
if n == 1:
	if A[0] == 1:
		print('YES')
	else:
		print('NO')
	exit()
count = 0
res = 1
for i in range(n):
	if A[i] == 0:
		count += 1
	if count > 1:
		res = 0
		break
if res == 1 and count == 1:
	print('YES')
else:
	print('NO')


n = int(input())
l = [int(x) for x in input().split()]
if n == 1:
	if l[0] == 1:
		print('YES')
	else:
		print('NO')
elif l.count(0) == 1:
	print('YES')
else:
	print('NO')


n = int(input())
arr = list(map(int, input().split()))
fastenedCount = 0
for i in range(n):
	if arr[i] == 1:
		fastenedCount += 1
if n == 1:
	if fastenedCount == 1:
		print('YES')
	else:
		print('NO')
elif fastenedCount == n - 1:
	print('YES')
else:
	print('NO')


def func():
	n = int(input())
	l = list(map(int, input().split()))
	count_fasten_button = 0
	if n == 1:
		if l[0] == 1:
			print('YES')
		else:
			print('NO')
		return
	for i in range(0, n):
		if l[i] == 0:
			count_fasten_button = count_fasten_button + 1
		if count_fasten_button > 1:
			break
	if count_fasten_button == 1:
		print('YES')
	else:
		print('NO')
func()


def is_fastened(btns):
	if len(btns) <= 1:
		btn = btns[0]
		return 'YES' if btn and btn == '1' else 'NO'
	count = 0
	for btn in btns:
		if btn == '0':
			count += 1
	if count == 1:
		return 'YES'
	return 'NO'

def main():
	n = input()
	btns = input()
	print(is_fastened(btns))
main()


n = int(input())
a = input().split()
per = 0
for i in a:
	if i == '0':
		per += 1
if n != 1:
	if per == 1:
		print('YES')
	else:
		print('NO')
elif per == 0:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
x = a.count(1)
if n == 1:
	if x == 1:
		print('YES')
	else:
		print('NO')
elif n == x + 1:
	print('YES')
else:
	print('NO')


n = int(input())
buttons = input()
n0 = buttons.count('0')
n1 = buttons.count('1')
if n == 1 and n1 == 1:
	print('YES')
elif n > 1 and n0 == 1:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
if n == 1:
	if a[0] == 1:
		print('YES')
	else:
		print('NO')
	exit()
count = 0
result = 1
for i in range(n):
	if a[i] == 0:
		count += 1
if count == 1:
	print('YES')
else:
	print('NO')


n = int(input())
l = list(map(int, input().split()))
if n == 1:
	if l[0] == 0:
		print('NO')
	else:
		print('YES')
if n > 1:
	k = 0
	for i in range(n):
		if l[i] == 0:
			k = k + 1
		if k > 1:
			break
if n > 1:
	if k == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
a = list(map(int, input().split()))
if n == 1:
	if a[0] == 1:
		print('YES')
	else:
		print('NO')
	exit(0)
tot = 0
for e in a:
	tot += e
if tot + 1 == n:
	print('YES')
else:
	print('NO')


a = input()
cnt = input().split().count('0')
if a == '1':
	print('YES' if cnt == 0 else 'NO')
else:
	print('YES' if cnt == 1 else 'NO')


n = int(input())
string = input()
buttons = list(map(int, string.split()))
(condition1, condition2) = (buttons.count(0) == 1 and n > 1, buttons[0] == 1 and n == 1)
if condition1 or condition2:
	print('YES')
else:
	print('NO')


(n, x) = (int(input()), [int(i) for i in input().split()])
print(('YES' if x[0] == 1 else 'NO') if n == 1 else 'YES' if sum(x) == n - 1 else 'NO')


n = int(input())
li = [int(x) for x in input().split()]
am1 = 0
for x in range(len(li)):
	if li[x] == 1:
		am1 += 1
if n == 1 and am1 == 1 or (n > 1 and am1 == 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')


import math
n = int(input())
s = input()
array = []
counter = 0
for i in s.split():
	array.append(int(i))
if len(array) == 1:
	if array[0] == 1:
		print('YES')
	else:
		print('NO')
else:
	for i in array:
		if i == 0:
			counter += 1
	if counter == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
l = list(map(int, input().split()))
check = True
if n == 1 and l[0] == 0 or l.count(0) > 1 or (l.count(0) == 0 and n > 1):
	check = False
print('YES' if check else 'NO')


t = input()
arr = input().split()
if len(arr) == 1 and arr.count('0') == 0:
	print('YES')
elif len(arr) != 1 and arr.count('0') == 1:
	print('YES')
else:
	print('NO')


N = int(input())
A = list(map(int, input().split()))
zero_count = 0
for x in A:
	if x == 0:
		zero_count += 1
if N == 1 and zero_count == 0 or (N > 1 and zero_count == 1):
	print('YES')
else:
	print('NO')


n = int(input())
b = [int(x) for x in input().split()]
sum = 0
for k in b:
	sum += k
if n == 1:
	if sum == 1:
		print('YES')
	else:
		print('NO')
elif n - sum == 1:
	print('YES')
else:
	print('NO')


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


li = []
n = int(input())
s = list(map(int, input().strip().split()))[:n]
f = 0
for i in range(len(s)):
	if s[i] is 1:
		li.append(s[i])
if len(li) > 0:
	if len(s) > 1 and len(li) == len(s):
		print('NO')
	elif len(s) is 1 and len(li) == len(s):
		print('YES')
	elif len(li) == len(s) - 1:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


def checkJacket(v, n):
	if n == 1:
		if v[0] == 1:
			return True
		return False
	cnt = 0
	for i in range(n):
		if v[i] == 0:
			cnt += 1
	if cnt == 1:
		return True
	return False
n = int(input())
v = list(map(int, input().split()))
if checkJacket(v, n):
	print('YES')
else:
	print('NO')


I = input
n = int(I())
a = sum(map(int, I().split()))
print(['NO', 'YES'][n < 2 and a > 0 or (n > 1 and a + 1 == n)])


number_of_buttons = int(input())
buttons = [int(x) for x in input().split()]
count = 0
if len(buttons) == 1:
	if buttons[0] == 0:
		print('NO')
	else:
		print('YES')
else:
	for button in buttons:
		if button == 0:
			count = count + 1
	if count == 1:
		print('YES')
	else:
		print('NO')


def main():
	input()
	s = input()[::1]
	print(('NO', 'YES')[s == '1' or (s != '0' and s.count('0') == 1)])
main()


import sys
from bisect import bisect_right as rb
from collections import deque
from queue import PriorityQueue
input_ = lambda : sys.stdin.readline().strip('\r\n')
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
ip = lambda : input_()
fi = lambda : float(input_())
ap = lambda ab, bc, cd: ab[bc].append(cd)
li = lambda : list(input_())
pr = lambda x: print(x)
prinT = lambda x: print(x)
f = lambda : sys.stdout.flush()
inv = lambda x: pow(x, mod - 2, mod)
mod = 10 ** 9 + 7
n = ii()
a = il()
if n == 1:
	if a[0] == 1:
		print('YES')
		exit(0)
	print('NO')
	exit(0)
if a.count(0) == 1:
	print('YES')
	exit(0)
print('NO')


input()
a = list(map(int, input().split()))
print(['NO', 'YES'][a.count(0) == 1 and len(a) != 1 or (len(a) == 1 and a.count(0) == 0)])


n = int(input())
a = list(map(int, input().split()))
b = [0] * 2
for i in a:
	b[i] += 1
if b[0] == 1 and b[1] > 0:
	print('YES')
elif b[0] == 0 and b[1] == 1:
	print('YES')
else:
	print('NO')


def main():
	count = int(input())
	data = input()
	l = data.split()
	if count == 1:
		print('YES' if l[0] == '1' else 'NO')
		return
	print('YES' if l.count('0') == 1 else 'NO')
main()


print('YES' if min(1, int(input()) - 1) == input().split().count('0') else 'NO')


numButton = int(input())
button = list(map(int, input().split()))
if numButton == 1:
	if button[0] == 1:
		print('YES')
	else:
		print('NO')
	exit()
count = 0
for i in range(0, numButton):
	if button[i] == 0:
		count += 1
if count == 1:
	print('YES')
else:
	print('NO')


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


def r():
	return list(map(int, input().split()))
n = r()[0]
arr = r()
if n == 1:
	print('NO' if arr[0] == 0 else 'YES')
else:
	print('YES' if sum(arr) == n - 1 else 'NO')


number_of_buttons = int(input())
buttons = list(map(int, input().split()))
if int(number_of_buttons) == 1:
	if buttons[0] == 0:
		print('NO')
	else:
		print('YES')
	exit()
count = 0
for button in buttons:
	if button == 0:
		count += 1
if count > 1 or count == 0:
	print('NO')
else:
	print('YES')


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


n = int(input())
lst = list(map(int, input().split()))
ans = 'YES'
cnt = 0
if len(lst) == 1:
	if lst[0] == 0:
		ans = 'NO'
else:
	for i in lst:
		if i == 0:
			cnt += 1
			if cnt > 1:
				break
	if cnt != 1:
		ans = 'NO'
print(ans)


n = int(input())
a = list(map(int, input().split()))
if n == 1:
	if a[0] == 0:
		print('NO')
	else:
		print('YES')
else:
	c = len([i for i in a if i == 1])
	if c == n - 1:
		print('YES')
	else:
		print('NO')


number_buttons = int(input())
buttons = list(map(int, input().strip().split()))

def check_is_fastened(my_number_buttons, my_buttons):
	if my_number_buttons == 1:
		if my_buttons[0] == 0:
			return 'NO'
		else:
			return 'YES'
	num_of_o = 0
	for button in my_buttons:
		if button == 0:
			num_of_o += 1
		if num_of_o > 1:
			return 'NO'
	if num_of_o == 1:
		return 'YES'
	else:
		return 'NO'
print(check_is_fastened(number_buttons, buttons))


n = int(input())
buttons = list(map(int, input().split()))
if n == 1:
	if buttons[0] == 1:
		print('YES')
	else:
		print('NO')
else:
	count = 0
	for i in range(0, n):
		if buttons[i] == 0:
			count = count + 1
		if count > 1:
			break
	if count == 1:
		print('YES')
	else:
		print('NO')


a = int(input())
c = input()
c = c.split()
if a == 1:
	if c[0] == '1':
		print('YES')
	else:
		print('NO')
else:
	z = c.count('0')
	if z == 1:
		print('YES')
	else:
		print('NO')


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


n = int(input())
p = input().rstrip().split(' ')
if len(p) == 1:
	if p[0] == '1':
		print('YES')
	else:
		print('NO')
else:
	t = p.count('0')
	y = p.count('1')
	if t == 1:
		print('YES')
	else:
		print('NO')


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


l = input().split()
btns = list(map(int, input().split()))
count = 0
if len(btns) == 1:
	if int(btns[0]) == 1:
		print('YES')
	else:
		print('NO')
else:
	for button in btns:
		if button == 0:
			count = count + 1
		if count >= 2:
			break
	if count >= 2 or count == 0:
		print('NO')
	else:
		print('YES')


n = int(input())
S = sum([int(x) for x in input().split()])
ans = False
if n == 1:
	ans = n == S
else:
	ans = n == S + 1
if ans:
	print('YES')
else:
	print('NO')


test = int(input())
count = input().split().count('0')
if count == 1 and test == 1:
	print('NO')
elif count == 0 and test == 1:
	print('YES')
elif count == 1:
	print('YES')
else:
	print('NO')


def check_jacket(n, l):
	if n == 1:
		if l[0] == 0:
			return 'NO'
		else:
			return 'YES'
	check = len(l) - sum(l)
	if check != 1:
		return 'NO'
	return 'YES'
n = int(input())
a = [int(x) for x in input().split()]
print(check_jacket(n, a))


n = int(input())
ai = [int(x) for x in input().split(' ')]
if n == 1:
	if ai[0] == 1:
		print('YES')
	else:
		print('NO')
	exit()
if ai.count(1) == n - 1:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split(' ')))
cntZero = 0
for x in a:
	if x == 0:
		cntZero = cntZero + 1
if n == 1 and cntZero == 0:
	print('YES')
elif n > 1 and cntZero == 1:
	print('YES')
else:
	print('NO')


import sys
n = int(input())
bs = input()
if n == 1:
	if bs == '0':
		print('NO')
	else:
		print('YES')
else:
	s = 0
	for a in bs[::2]:
		if a == '0':
			s += 1
		if s > 1:
			print('NO')
			sys.exit()
	if s == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
ans = 0
a = list(map(int, input().split()))
if n == 1:
	if a[0] == 1:
		print('YES')
	else:
		print('NO')
else:
	for i in range(n):
		if a[i] == 0:
			ans += 1
	if ans == 1:
		print('YES')
	else:
		print('NO')


import re

def main():
	n = int(input())
	if n > 1:
		ok = 1 == len(re.findall('0', input()))
	else:
		ok = input() == '1'
	print('YES' if ok else 'NO')
main()


n = int(input())
a = list(map(int, input().split()))
c = a.count(0)
if (c > 1 or c < 1) and n > 1:
	print('NO')
elif n == 1 and c == 1:
	print('NO')
else:
	print('YES')


num_of_buttons = int(input())
arr_of_buttons = list(map(int, input().split()))

def main():
	count = 0
	if num_of_buttons == 1:
		if arr_of_buttons[0] == 1:
			print('YES')
		else:
			print('NO')
		return
	for i in range(num_of_buttons):
		if arr_of_buttons[i] == 0:
			count += 1
	if count == 1:
		print('YES')
	else:
		print('NO')
	return
main()


a = input()
c = input().split()
b = []
for i in range(int(a)):
	d = c[i]
	b.append(int(d))
if len(b) > 2:
	dem = 0
	for i in b:
		if int(i) == 0:
			dem += 1
	if dem == 1:
		print('YES')
	else:
		print('NO')
elif len(b) == 2:
	if (b[0] == 0) & (b[1] == 0) | (b[0] == 1) & (b[1] == 1):
		print('NO')
	else:
		print('YES')
elif len(b) == 1:
	if b[0] == 1:
		print('YES')
	else:
		print('NO')


def main():
	n = int(input()) - 1
	k = input().split().count('1')
	res = 'NO'
	if 0 != n and n == k:
		res = 'YES'
	if 0 == n and 1 == k:
		res = 'YES'
	print(res)
main()


n = int(input())
bs = input()

def f(n, bs):
	if n == 1:
		if bs == '0':
			print('NO')
		else:
			print('YES')
	else:
		s = 0
		for a in bs[::2]:
			if a == '0':
				s += 1
			if s > 1:
				print('NO')
				return
		if s == 1:
			print('YES')
		else:
			print('NO')
f(n, bs)


n = int(input())
a = list(map(int, input().split()))
ok = False
if n == 1:
	if a[0] == 1:
		ok = True
else:
	cnt = 0
	for i in a:
		if i == 1:
			cnt += 1
	if cnt == len(a) - 1:
		ok = True
if ok:
	print('YES')
else:
	print('NO')


def main():
	n = int(input())
	check = 0
	arr = input().split(' ')
	for i in range(len(arr)):
		if int(arr[i]) == 0:
			check += 1
	if n == 1:
		if check == 0:
			print('YES')
		else:
			print('NO')
	elif check == 1:
		print('YES')
	else:
		print('NO')
main()


n = int(input())
li = list(map(int, input().split()))
sum_li = sum(li, 0)
res = None
if n == 1:
	if sum_li == 1:
		res = 'YES'
	else:
		res = 'NO'
elif sum_li == n - 1:
	res = 'YES'
else:
	res = 'NO'
print(res)


line = input()
line2 = input()
total = int(line)
arrayValue = line2.split(' ')

def checkValid(total, arrayValue):
	if total == 1:
		if arrayValue[-1] == '0':
			print('NO')
		else:
			print('YES')
	else:
		fastened = 0
		for i in range(total):
			if arrayValue[i] == '0':
				fastened += 1
				if fastened > 1:
					break
		if fastened == 1:
			print('YES')
		else:
			print('NO')
checkValid(total, arrayValue)


jacketNumber = ''
jacketList = ''
jacketNumber = int(input())
jacketList = input()
jacketList = jacketList.split()
if len(jacketList) == 1:
	if int(jacketList[0]) == 1:
		print('YES')
	else:
		print('NO')
else:
	unFastened = []
	for i in range(len(jacketList)):
		if int(jacketList[i]) == 0:
			unFastened.append(0)
		if len(unFastened) > 1:
			break
	if len(unFastened) == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
r = lambda : list(map(int, input().split()))
arr = r()
one = arr.count(1)
if n == 1:
	print('YES' if one else 'NO')
else:
	print('YES' if n - one == 1 else 'NO')


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


n = int(input())
buttonstate = list(map(int, input().split()))
if n == 1:
	c = buttonstate.count(1)
	if c > 0:
		print('YES')
	else:
		print('NO')
else:
	c = buttonstate.count(1)
	d = buttonstate.count(0)
	if c > 0 and d == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
s = input()
buttons = [int(x) for x in s.split()]
cnt = 0
for b in buttons:
	if b == 0:
		cnt += 1
if n == 1:
	print('YES') if cnt == 0 else print('NO')
else:
	print('YES') if cnt == 1 else print('NO')


n = int(input())
arr = list(map(int, input().split()))
t = 0
if n == 1:
	if arr[0] == 1:
		print('YES')
	else:
		print('NO')
else:
	for i in arr:
		if i == 0:
			t += 1
	if t == 1:
		print('YES')
	else:
		print('NO')


buttons = int(input())
fastens = list(map(int, input().split()))
count = 0
if buttons == 1:
	if fastens[0] == 0:
		print('NO')
		exit()
	else:
		print('YES')
		exit()
else:
	for fasten in fastens:
		if fasten == 0:
			count += 1
	if count == 1:
		print('YES')
	else:
		print('NO')


def is_fastened_jacket(n, a):
	count = 0
	if n == 1:
		if a[0] == 1:
			return 'YES'
		else:
			return 'NO'
	else:
		for i in range(len(a)):
			if a[i] == 0:
				count += 1
			if count > 1:
				return 'NO'
		return 'NO' if count == 0 else 'YES'
n = int(input())
a = [int(i) for i in input().split()]
print(is_fastened_jacket(n, a))


n = int(input())
tuxedo = input().split()
print('YES' if n == 1 and tuxedo[0] == '1' or (n != 1 and tuxedo.count('0') == 1) else 'NO')


n = int(input())
l = list(map(int, input().split()))
if l.count(0) == 1 and len(l) > 1 or (len(l) == 1 and l[0] == 1):
	print('YES')
else:
	print('NO')


n = int(input())
buttons = list(map(int, input().split()))
if n == 1:
	if buttons[0] == 1:
		print('YES')
	else:
		print('NO')
elif buttons.count(0) == 1:
	print('YES')
else:
	print('NO')


n = int(input())
a = []
line = input()
if line:
	for x in line.strip().split():
		a.append(int(x))
	b = sum(a)
	if n == 1:
		if b == 1:
			print('YES')
		else:
			print('NO')
	elif b == n - 1:
		print('YES')
	else:
		print('NO')


import sys

def main():
	n = int(sys.stdin.readline().strip())
	a = stdin_get_ints_from_line()
	if n == 1 and a[0] == 0:
		print('NO')
		return
	if n == 1 and a[0] == 1:
		print('YES')
		return
	if sum(a) == n - 1:
		print('YES')
	else:
		print('NO')

def stdin_get_ints_from_line():
	return list((int(x) for x in sys.stdin.readline().strip().split(' ')))
main()


n = input()
x = input().split().count('0')
if n == '1' and x == 1:
	print('NO')
elif n == '1' and x == 0:
	print('YES')
elif x == 1:
	print('YES')
else:
	print('NO')


n = int(input())
A = list(map(int, input().split()))
if n == 1:
	if A[0] == 1:
		print('YES')
	else:
		print('NO')
else:
	cnt = 0
	for i in range(0, len(A)):
		if A[i] == 0:
			cnt += 1
		if cnt > 1:
			break
	if cnt == 1:
		print('YES')
	else:
		print('NO')


n = input()
list = [int(x) for x in input().split()]
count = 0
for i in range(0, len(list)):
	k = list[i]
	if k == 0:
		count += 1
if len(list) == 1:
	if count == 0:
		print('YES')
	else:
		print('NO')
elif count == 1:
	print('YES')
else:
	print('NO')


n = int(input())
arr = list(map(int, input().split()))
if len(arr) == 1:
	if arr[0] == 1:
		print('YES')
	else:
		print('NO')
elif n == sum(arr) + 1:
	print('YES')
else:
	print('NO')


print(('NO', 'YES')[(input() == '1') ^ (input().count('0') == 1)])


n = int(input())
a = list(map(int, input().split()))
i = 0
k = 0
while i < len(a) and k <= 1:
	if a[i] == 0:
		k += 1
		i += 1
	else:
		i += 1
if k == 1 and len(a) > 1:
	print('YES')
elif k == 0 and len(a) == 1:
	print('YES')
else:
	print('NO')


def process(num, list_):
	if num == 1:
		if list_[0] == 0:
			return 'NO'
		else:
			return 'YES'
	else:
		count_0 = 0
		for i in list_:
			if i == 0:
				count_0 += 1
			if count_0 > 1:
				return 'NO'
		if count_0 == 1:
			return 'YES'
		else:
			return 'NO'
num = int(input().strip())
list_ = list(map(int, input().strip().split()))
print(process(num, list_))


def faster():
	buttons = int(input())
	listb = list(map(int, input().split()))
	if buttons == 1:
		if listb[0] == 1:
			return 'YES'
		else:
			return 'NO'
	count = 0
	for i in range(0, buttons, 1):
		if listb[i] == 0:
			count = count + 1
			if count > 1:
				return 'NO'
	if count == 0:
		return 'NO'
	return 'YES'
print(faster())


n = int(input())
a = list(map(int, input().split()))
flag = True
count = 0
for i in range(len(a)):
	if len(a) >= 2:
		if a[i] == 0:
			count += 1
if count != 1:
	flag = False
if n == 1:
	if a[0] == 0:
		print('NO')
	else:
		print('YES')
elif flag == False:
	print('NO')
else:
	print('YES')


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

def check(a, n):
	count = 0
	if n == 1:
		if a[0] == 1:
			return 'YES'
		else:
			return 'NO'
	for i in range(n):
		if a[i] == 0:
			count += 1
	if count == 1:
		return 'YES'
	else:
		return 'NO'
print(check(a, n))


def solve(kase):
	return

def main():
	N = int(input())
	buttons = [int(x) for x in input().split()]
	fastened = sum(buttons)
	if N == 1:
		if fastened > 0:
			print('YES')
		else:
			print('NO')
	elif fastened == N - 1:
		print('YES')
	else:
		print('NO')
main()


n = int(input())
buttons = input().split()
if n == 1:
	print('YES' if buttons[0] == '1' else 'NO')
else:
	try:
		buttons.remove('0')
	except:
		print('NO')
	else:
		print('YES' if '0' not in buttons else 'NO')


n = int(input())
a = []
a = input().split()
k = 0
for i in range(n):
	if a[i] == '0':
		k += 1
if n > 1 and k == 1 or (k == 0 and n == 1):
	print('YES')
else:
	print('NO')


x = int(input())
if x == 1:
	r = int(input())
	if r == 0:
		print('NO')
	else:
		print('YES')
else:
	mas = input().split()
	mas.sort()
	s = 0
	for i in range(x):
		if s > 1:
			print('NO')
			break
		if int(mas[i]) == 0:
			s = s + 1
	else:
		if s == 1:
			print('YES')
		else:
			print('NO')


n = int(input())
cnt = 0
s = input()
a = s.split(' ')
for i in range(n):
	if a[i] == '0':
		cnt += 1
if n == 1 and cnt == 0:
	print('YES')
elif n != 1 and cnt == 1:
	print('YES')
else:
	print('NO')


from sys import stdin, stdout

def main():
	number_of_buttons = int(stdin.readline().rstrip())
	buttons = stdin.readline().rstrip()
	buttons = [int(i) for i in buttons.split()]
	if number_of_buttons == 1:
		if buttons[0] == 1:
			return 'YES'
		return 'NO'
	if sum(buttons) == number_of_buttons - 1:
		return 'YES'
	return 'NO'
print(main())


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')


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().strip())
x = list(map(int, input().strip().split(' ')))
if n == 1:
	if sum(x) == 1:
		print('YES')
	else:
		print('NO')
elif n - sum(x) == 1:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
zeroes = a.count(0)
ones = n - zeroes
if zeroes == 1 and ones > 0:
	print('YES')
elif n == 1 and zeroes == 0:
	print('YES')
else:
	print('NO')


n = int(input())
a = input()
if n == 1 and a == '1':
	result = 'YES'
elif n == 1 and a == '0':
	result = 'NO'
else:
	a = a.split(' ')
	check = 0
	result = 'NO'
	for i in range(n):
		if a[i] == '0' and check == 0:
			check = 1
			result = 'YES'
		elif a[i] == '0' and check == 1:
			result = 'NO'
			break
print(result)


fasten = False
number_of_buttons = int(input())
buttons = list(map(int, input().split()))
if len(buttons) == 1:
	if buttons[0] == 1:
		fasten = True
else:
	unfasten_buttons = list(filter(lambda x: x == 0, buttons))
	if len(unfasten_buttons) == 1:
		fasten = True
print('YES') if fasten else print('NO')


b = int(input())
a = [int(i) for i in input().split()]
k = 0
if b == 1:
	if a[0] == 0:
		print('NO')
	else:
		print('YES')
else:
	for i in a:
		if i == 0:
			k += 1
	if k == 1:
		print('YES')
	else:
		print('NO')


def main():
	n = int(input())
	buttons = list(map(int, input().split()))
	if len(buttons) == 1:
		if buttons[0] == 1:
			print('YES')
			return True
		else:
			print('NO')
			return False
	hasButton = False
	for i in range(0, len(buttons)):
		if buttons[i] == 0:
			if hasButton:
				print('NO')
				return False
			else:
				hasButton = True
	if not hasButton:
		print('NO')
		return False
	print('YES')
	return True
main()


n = int(input())
text = input()
sch = 0
for i in range(0, n):
	if int(text.split(' ')[i]) == 0:
		sch += 1
if sch == 0 and n == 1:
	print('YES')
elif sch == 1 and n == 1:
	print('NO')
elif sch == 1:
	print('YES')
else:
	print('NO')


n = int(input())
L = [int(x) for x in input().split()]
cnt = len([i for i in L if i == 1])
if n == 1 and cnt == 1:
	print('YES')
elif n > 1 and cnt == n - 1:
	print('YES')
else:
	print('NO')


def main():
	n = int(input())
	arr = list(map(int, input().split()))
	total = sum(arr)
	if n == 1 and total == 1:
		print('YES')
	elif n >= 2 and total == n - 1:
		print('YES')
	else:
		print('NO')
main()


input()
n = input()
answer = 'NO'
if len(n) != 1 and n.count('0') == 1 or n == '1':
	answer = 'YES'
print(answer)


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
n = ii()
a = li()
if n == 1 and a[0] or (n != 1 and a.count(0) == 1):
	print('YES')
else:
	print('NO')


n = int(input())
buttons = input()
if len(buttons) == 1:
	if buttons == '1':
		print('YES')
	else:
		print('NO')
elif buttons.count('0') == 1:
	print('YES')
else:
	print('NO')


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

def checkFashion(array):
	count_0 = 0
	if len(array) == 1:
		if array[0] == 1:
			print('YES')
			return
		else:
			print('NO')
			return
	for i in range(len(array)):
		if array[i] == 0:
			count_0 += 1
	if (count_0 > 1) | (count_0 == 0):
		print('NO')
	else:
		print('YES')
checkFashion(arr)


n = int(input())
a = [int(x) for x in input().split()]
if n == 1:
	print('YES' if a[0] == 1 else 'NO')
else:
	print('YES' if a.count(1) == n - 1 else 'NO')


n = int(input())
l = [int(i) for i in input().split()]
if n == 1:
	if l[0] == 1:
		print('YES')
	else:
		print('NO')
	exit()
if sum(l) == n - 1:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
if len(a) == 0:
	print('NO')
elif len(a) == 1 and a[0] == 1:
	print('YES')
elif len(a) == 1 and a[0] == 0:
	print('NO')
else:
	cnt0 = a.count(0)
	if cnt0 == 1:
		print('YES')
	else:
		print('NO')


n_buttons = input()
array = [i for i in input() if i == '0' or i == '1']
fasten = 0
if len(array) > 1:
	for i in array:
		if i == '1':
			fasten += 1
	if fasten == len(array) - 1:
		print('YES')
	else:
		print('NO')
if len(array) == 1:
	if array[0] == '1':
		print('YES')
	else:
		print('NO')


n = int(input())
array = [int(i) for i in input().split()]
if n == 1:
	if sum(array) == 1:
		print('YES')
	else:
		print('NO')
elif sum(array) == n - 1:
	print('YES')
else:
	print('NO')


num_cases = int(input())
a = [int(x) for x in input().split(' ')]
countZeros = 0
for x in a:
	if x == 0:
		countZeros += 1
if num_cases == 1:
	print('YES') if countZeros == 0 else print('NO')
else:
	print('YES') if countZeros == 1 else print('NO')


n = int(input())
ls = list(map(int, input().split()))
cnt = 0
flag = True
if n == 1:
	if ls[0] == 0:
		flag = False
else:
	for i in range(n):
		if ls[i] == 0:
			cnt += 1
	if cnt != 1:
		flag = False
if flag:
	print('YES')
else:
	print('NO')


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


num = int(input())
string = str(input())
if num == 1 and string == '1':
	print('YES')
elif num == 1 and string == '0':
	print('NO')
elif not string.count('0') == 1:
	print('NO')
else:
	print('YES')


import sys
n = int(input())
a = input().split()
count = 0
num = ''.join(a)
z = str(num)
if z == '1':
	print('YES')
	sys.exit()
y = num.count('0')
if y == 1 and n > 1:
	print('YES')
else:
	print('NO')


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


n = int(input())
num = list(map(int, input().split()))
ans = 0
for i in num:
	ans += i
if n == 1:
	if ans == 1:
		print('YES')
	else:
		print('NO')
elif ans == n - 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 = int(input())
l = list(map(int, input().split()))
if sum(l) == max(1, n - 1):
	print('YES')
else:
	print('NO')


n = int(input())
a = list(input())
count = 0
for i in a:
	if i == ' ':
		a.remove(i)
if len(a) == 1:
	if a[0] == '0':
		print('NO')
	else:
		print('YES')
else:
	for i in a:
		if i == '0':
			count += 1
	if count == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
arr = [int(i) for i in input().split(' ')]
answer = 'NO'
if n == 1:
	if arr[0] == 1:
		answer = 'YES'
else:
	numberOfFastenedButtons = 0
	for button in arr:
		if button == 1:
			numberOfFastenedButtons += 1
	if numberOfFastenedButtons == n - 1:
		answer = 'YES'
print(answer)


__author__ = 'artyom'

def main():
	n = read()
	a = read(2)
	if n == 1:
		return a[0] == '1'
	return a.count('0') == 1

def read(mode=1, size=None):
	if mode == 0:
		return input().strip()
	if mode == 1:
		return int(input().strip())
	if mode == 2:
		return input().strip().split()
	if mode == 3:
		return list(map(int, input().strip().split()))
	a = []
	for _ in range(size):
		a.append(read(3))
	return a

def write(s='\n'):
	if s is None:
		s = ''
	if isinstance(s, tuple) or isinstance(s, list):
		s = ' '.join(map(str, s))
	s = str(s)
	print(s, end='\n')
write(['NO', 'YES'][main()])


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


n = int(input())
a = list(map(int, input().split()))
cnt = 0
if n == 1:
	if a[0] == 1:
		print('YES')
	else:
		print('NO')
	exit()
for i in range(n):
	if a[i] == 0:
		cnt += 1
		if cnt >= 2:
			break
if cnt == 1:
	print('YES')
else:
	print('NO')


def check(mylist):
	if len(mylist) == 1:
		if mylist.count(1) == 1:
			print('YES')
		else:
			print('NO')
	elif mylist.count(0) == 1:
		print('YES')
	else:
		print('NO')
n = int(input())
mylist = list(map(int, input().split(' ')))
check(mylist)


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


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
if n == 1:
	if arr[0] == 1:
		print('YES')
	else:
		print('NO')
else:
	t = 0
	for i in range(2):
		if arr[i] == 0:
			t += 1
	if t == 2 or t == 0:
		print('NO')
	else:
		print('YES')


line1 = int(input())
line2 = list(map(int, input().split()))
num_zero = 0
if line1 == 1:
	if line2[0] == 1:
		print('YES')
		exit()
	else:
		print('NO')
		exit()
elif line1 >= 2:
	for item in line2:
		if item == 0:
			num_zero = num_zero + 1
	if num_zero == 1:
		print('YES')
	else:
		print('NO')


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


numberOfButton = int(input())
buttons = list(map(int, input().split()))
total = 0
if numberOfButton == 1:
	if buttons[0] == 1:
		print('YES')
	else:
		print('NO')
else:
	for i in range(len(buttons)):
		total = total + buttons[i]
	if total == numberOfButton - 1:
		print('YES')
	else:
		print('NO')


from sys import stdin
n = int(input())
boutons = list(map(int, stdin.readline().split()))
boucles = 0
for bouton in boutons:
	if bouton:
		boucles += 1
if n == 1 and boutons[0] or (n > 1 and boucles == n - 1):
	print('YES')
else:
	print('NO')


user = int(input())
s = list(input().split(' '))
c = 0
if user == 1 and int(s[0]) == 1:
	print('YES')
elif user == 1 and int(s[0]) == 0:
	print('NO')
else:
	for i in s:
		if int(i) == 0:
			c += 1
	if c == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
array = []
str = input()
for i in str.split():
	array.append(int(i))
s = sum(array)
if n == 1:
	print('YES' if s == 1 else 'NO')
else:
	print('YES' if s == n - 1 else 'NO')


n = int(input())
A = list(map(int, input().split()))
if len(A) == 1:
	if A[0] == 1:
		print('YES')
	else:
		print('NO')
else:
	count = 0
	for i in range(len(A)):
		if A[i] == 0:
			count += 1
		if count > 1:
			print('NO')
			exit()
	if count != 1:
		print('NO')
	else:
		print('YES')


fastened = 0
notfastened = 0
buttons = []
a = int(input())
buttons = list(map(int, input().split()))
for i in range(a):
	if buttons[i] == 1:
		fastened += 1
	else:
		notfastened += 1
	if notfastened >= 2:
		print('NO')
		exit()
	if len(buttons) == 1:
		if buttons[0] == 0:
			print('NO')
			exit()
		else:
			print('YES')
			exit()
if notfastened == 1:
	print('YES')
else:
	print('NO')


numberOfButtons = ''
numberOfButtons = input()
buttons = []
buttons = input()
unfastened = 0
if numberOfButtons == '1':
	if buttons[0] == '0':
		print('NO')
	else:
		print('YES')
	exit()
for button in buttons:
	if button == '0':
		unfastened += 1
	if unfastened >= 2:
		print('NO')
		exit()
if unfastened == 0:
	print('NO')
	exit()
print('YES')


def count(l, n):
	cnt = 0
	if n == 1:
		if l[0] == 1:
			return True
		else:
			return False
	else:
		for i in l:
			if i != 1:
				cnt = cnt + 1
				if cnt > 1:
					return False
		if cnt == 0:
			return False
		return True
n = int(input().strip())
s = input().strip()
s = s.split(' ')
s = [int(j) for j in s]
if count(s, n):
	print('YES')
else:
	print('NO')


n = int(input())
buttons = input()
if n == 1:
	if int(buttons) == 1:
		print('YES')
	else:
		print('NO')
else:
	button_list = buttons.split(' ')
	count = 0
	for i in button_list:
		if int(i) == 1:
			count += 1
	if count == n - 1:
		print('YES')
	else:
		print('NO')


n = int(input())
nums = [int(x) for x in input().split()]
flag = 'YES'
if n == 1 and nums[0] == 0:
	flag = 'NO'
elif n > 1:
	if sum(nums) != n - 1:
		flag = 'NO'
print(flag)


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')
elif a != n - 1:
	print('NO')
else:
	print('YES')


n = int(input())
ls = [int(x) for x in input().split()]
sum = sum(ls)
if n == 1:
	if sum == n:
		print('YES')
	else:
		print('NO')
elif sum == 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()


a = int(input())
b = str(input()).split()
c = 0
for i in b:
	if int(i) == 1:
		c += 1
if a == 1 and c == 1:
	print('YES')
elif a > 1 and c == a - 1:
	print('YES')
else:
	print('NO')


n = int(input())
x = 0
a = list(map(int, input().split()))
if len(a) > 1:
	for i in range(len(a)):
		if a[i] == 0:
			x = x + 1
	if x == 1:
		print('YES')
	else:
		print('NO')
elif a[0] == 1:
	print('YES')
else:
	print('NO')


n = int(input())
A = list(map(int, input().split()))
from collections import Counter
C = Counter(A)
if n == 1:
	if C[1] == 1:
		print('YES')
	else:
		print('NO')
elif C[1] == n - 1:
	print('YES')
else:
	print('NO')


N = int(input())
arr = list(map(int, input().split(' ')))
if N == 1:
	if arr[0] == 1:
		print('YES')
	else:
		print('NO')
else:
	c = 0
	for i in range(N):
		if arr[i] == 0:
			c += 1
	if c == 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')
elif n - num == 1:
	print('YES')
else:
	print('NO')


input()
btns = list(map(int, input().split(' ')))
if len(btns) == 1:
	print('YES' if btns[0] == 1 else 'NO')
else:
	count_0 = 0
	for btn in btns:
		if btn == 0:
			count_0 += 1
	print('NO' if count_0 != 1 else 'YES')


count = 0
quantity = int(input().strip())
buttons = list(map(int, input().strip().split()))
for i in buttons:
	if i == 0:
		count += 1
if count == 0 and len(buttons) == 1:
	print('YES')
elif count != 1 or (count == 1 and len(buttons) == 1):
	print('NO')
else:
	print('YES')


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


n = int(input())
l = len(list(filter(lambda v: v == 0, map(int, input().split()))))
print('YES' if l == 1 and n > 1 or (l == 0 and n == 1) else 'NO')


def main():
	n = int(input())
	x = [int(i) for i in input().split()]
	if n == 1 and x[0] == 1:
		return 'YES'
	if n == 1 and x[0] == 0:
		return 'NO'
	if n - 1 == x.count(1):
		return 'YES'
	return 'NO'
print(main())


import sys
total = int(str(sys.stdin.readline().strip('\n')))
str_list = sys.stdin.readline().strip('\n').split(' ')
number_list = [int(str(i)) for i in str_list]
actual_total = sum(number_list)
if total == 1:
	if actual_total == 1:
		print('YES')
	else:
		print('NO')
elif actual_total == total - 1:
	print('YES')
else:
	print('NO')


buttons = int(input())
sign = [int(i) for i in input().split()]
if buttons == 1:
	if sign[0] == 1:
		print('YES')
	else:
		print('NO')
elif sign.count(0) == 1:
	print('YES')
else:
	print('NO')


n = int(input())
m = sum(list(map(int, input().split())))
if n is 1 and m is 1 or (n - m is 1 and n is not 1):
	print('YES')
else:
	print('NO')


n = int(input())
m = list(map(int, input().split()))
count = 0
if n == 1 and m[0] == 1:
	print('YES')
	exit(0)
for i in range(n):
	if m[i] == 0:
		count += 1
if count == 1 and n > 1:
	print('YES')
else:
	print('NO')


n = int(input())
bs = input()
if bs == '1':
	print('YES')
elif bs == '0':
	print('NO')
else:
	s = 0
	for a in bs[::2]:
		s += int(a)
	if s != n - 1:
		print('NO')
	else:
		print('YES')


notFastened = 0
buttons = int(input())
line = list(map(int, input().split()))
for i in range(len(line)):
	fastened = line[i]
	notFastened += fastened == 0
if buttons == 1 and notFastened == 0 or (buttons != 1 and notFastened == 1):
	print('YES')
else:
	print('NO')


print('YES' if (input() != '1') == input().count('0') else 'NO')


a = input()
b = input()
c = b.split()
dem = 0
if int(a) == 1:
	if int(c[0]) == 1:
		print('YES')
	else:
		print('NO')
else:
	for i in range(int(a)):
		if int(c[i]) == 0:
			dem += 1
	if dem == 1:
		print('YES')
	else:
		print('NO')


from collections import Counter
n = int(input())
c = Counter(input().split())
if n == 1:
	if c['0'] == 0:
		print('YES')
	else:
		print('NO')
elif c['0'] == 1:
	print('YES')
else:
	print('NO')


n = int(input())
button = list(input().split())
if n == 1:
	if button[0] == '1':
		print('YES')
	else:
		print('NO')
else:
	c = 0
	for i in button:
		if i == '1':
			continue
		else:
			c += 1
	if c == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
stroka = input()
a = [50] * n
l = 0
if n == 1:
	stroka = int(stroka)
	if stroka == 1:
		print('YES')
	else:
		print('NO')
else:
	for i in range(n):
		a[i] = int(stroka[2 * i])
		if a[i] == 0:
			l += 1
	if l == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
d = 0
x = input()
list1 = x.split()
for i in range(n):
	if list1[i] == '0':
		d = d + 1
if n == 1 and d == 0:
	print('YES')
elif n != 1 and d == 1:
	print('YES')
else:
	print('NO')


import sys
count = 0
for line in sys.stdin:
	if count == 0:
		num = int(line.strip())
		count += 1
		continue
	ll = [int(i) for i in line.strip().split(' ')]
flag = 0
if num > 1:
	if sum(ll) != len(ll) - 1:
		flag = -1
elif ll[0] == 0:
	flag = -1
if flag < 0:
	print('NO')
else:
	print('YES')


def problem691A(num_buttons):
	passed = True
	count_zero = 0
	a = list(map(int, input().split()))
	for i in range(num_buttons):
		x = a[i]
		if x == 0:
			count_zero += 1
		if num_buttons == 1:
			passed = x == 1
		else:
			passed = count_zero == 1
	return 'YES' if passed else 'NO'
n = int(input())
res = problem691A(n)
print(res)


n = int(input())
if n == 1:
	str = int(input())
	if str == 1:
		print('YES')
	else:
		print('NO')
else:
	str = list(map(int, input().split()))
	count = 0
	flag = True
	for i in range(n):
		if str[i] == 0:
			count += 1
		if count == 2:
			flag = False
			break
	if count == 0:
		flag = False
	if flag == True:
		print('YES')
	else:
		print('NO')


testcase = int(input())
num = list(map(int, input().split()))[:testcase]
l = len(num)
countofOne = 0
if l == 1:
	if num[0] == 0:
		print('NO')
	else:
		print('YES')
else:
	for i in range(l):
		if num[i] == 1:
			countofOne += 1
	if countofOne == l - 1:
		print('YES')
	else:
		print('NO')


def Count(l):
	if len(l) == 1:
		if l[0] == 0:
			return False
		else:
			return True
	zeros = 0
	for i in l:
		if i == 0:
			if zeros == 0:
				zeros += 1
			else:
				return False
	if zeros == 1:
		return True
	return False
n = int(input())
li = list(map(int, input().split()))
if Count(li):
	print('YES')
else:
	print('NO')


import sys
buttons = int(input())
jacket = input()
my_vector = []
for i in range(len(jacket)):
	if i % 2 == 0:
		my_vector.append(int(jacket[i]))
if buttons == 1:
	if my_vector[0] == 1:
		print('YES')
		sys.exit()
	else:
		print('NO')
		sys.exit()
else:
	count = 0
	for i in my_vector:
		if i == 0:
			count += 1
		if count > 1:
			print('NO')
			sys.exit()
if count == 1:
	print('YES')
else:
	print('NO')


num_buttons = int(input())
buttons = input().split()
count = 0
for index in range(num_buttons):
	if buttons[index] == '0':
		count += 1
	if count == 2:
		break
if count == 1 and num_buttons > 1 or (count == 0 and num_buttons == 1):
	print('YES')
else:
	print('NO')


def pygovitsi(lst):
	if len(lst) == 1 and lst[0] == 1:
		return 'YES'
	elif len(lst) == 1 and lst[0] == 0:
		return 'NO'
	elif len(lst) > 1:
		a = lst.count(1)
		b = lst.count(0)
		if a > 0 and b == 1:
			return 'YES'
		else:
			return 'NO'
n = int(input())
x = [int(i) for i in input().split()]
print(pygovitsi(x))


n = int(input())
l = list(map(int, input().split()))
if n == 1:
	if l.count(0) == 1:
		print('NO')
	else:
		print('YES')
else:
	x = l.count(0)
	if x == 1:
		print('YES')
	else:
		print('NO')


total = input()
total = int(total)
btns = input()
btns.split(' ')
if len(btns) < total:
	print('NO')
elif len(btns) == 1:
	if btns[0] == '1':
		print('YES')
	else:
		print('NO')
else:
	count = 0
	for x in btns:
		if x == '0':
			count += 1
	if count > 1 or count == 0:
		print('NO')
	else:
		print('YES')


buttons = input()
fastened = input()
f_list = fastened.split()
counter = 0
if len(f_list) != int(buttons):
	print('NO')
elif len(f_list) == 1:
	if f_list[0] == '1':
		print('YES')
	else:
		print('NO')
else:
	for i in range(len(f_list)):
		if f_list[i] == '0':
			counter += 1
	if counter != 1:
		print('NO')
	else:
		print('YES')


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')


def FashionInBerland(n, a):
	count = 0
	if n == 1:
		if a[0] == 1:
			return 'YES'
		else:
			return 'NO'
	else:
		for i in a:
			if i == 0:
				count += 1
	if count == 1:
		return 'YES'
	else:
		return 'NO'
n = int(input())
a = [int(x) for x in input().split()]
print(FashionInBerland(n, a))


n = int(input())
a = input()
print('NYOE S'[n < 2 and a.count('1') or (n > 1 and a.count('0') == 1)::2])


N = int(input())
S = input()
res = False
if N == 1 and S.count('1') == 1:
	res = True
elif N > 1 and S.count('1') == N - 1:
	res = True
print('YES' if res else 'NO')


n = input()
m = input()
m = str(m)
n = int(n)
k = 0
if n > 1:
	for num in m.split():
		if int(num) == 1:
			k += 1
	if k == n - 1:
		print('YES')
	else:
		print('NO')
elif n == 1:
	for num in m.split():
		if int(num) == 1:
			print('YES')
		else:
			print('NO')


n = int(input())
a = list(map(int, input().split()))
buttons = a.count(1)
if n == 1:
	if buttons == 1:
		print('YES')
	else:
		print('NO')
	exit()
elif buttons == n - 1:
	print('YES')
else:
	print('NO')


def main():
	n = int(input())
	a = [int(x) for x in input().split()]
	ones = a.count(1)
	if n == 1:
		print(ones == 1 and 'YES' or 'NO')
	else:
		print(ones == n - 1 and 'YES' or 'NO')
main()


n = int(input())
lst = list(map(int, input().split()))
count = 0
for item in lst:
	if item == 0:
		count += 1
if len(lst) == 1 and lst[0] == 0 or count > 1 or (len(lst) > 1 and count == 0):
	print('NO')
else:
	print('YES')


n = int(input(''))
s = input('').split(' ')
count = 0
myList = []
while count < n:
	myList.append(int(s[count]))
	count = count + 1
if n == 1:
	if myList[0] == 1:
		print('YES')
	else:
		print('NO')
else:
	mysum = sum(myList)
	if mysum == n - 1:
		print('YES')
	else:
		print('NO')


n = int(input())
list_ = [int(x) for x in input().split()]

def first():
	count = 0
	if n == 1 and list_[0] == 1:
		print('YES')
		return
	elif n == 1 and list_[0] == 0:
		print('NO')
		return
	else:
		for i in range(n):
			if list_[i] == 0:
				count = count + 1
			if count > 1:
				print('NO')
				return
		if count == 1:
			print('YES')
			return
		else:
			print('NO')
			return
first()


def R():
	return map(int, input().split())

def I():
	return int(input())

def S():
	return str(input())

def L():
	return list(R())
from collections import Counter
import math
import sys
from itertools import permutations
import bisect
n = I()
a = L()
cnt = sum([a[i] == 0 for i in range(n)])
print(['NO', 'YES'][cnt == 1 and n > 1 or (cnt == 0 and n == 1)])


def solution():
	input()
	l = input().strip().split()
	if len(l) == 1:
		print('YES' if l[0] == '1' else 'NO')
		return
	print('YES' if l.count('0') == 1 else 'NO')
solution()


n = int(input())
x = input().count('0')
print('YES' if x == (n != 1) else 'NO')


n = int(input())
a = list(map(int, input().split()))
if n == 1:
	if a[0] == 1:
		print('YES')
	else:
		print('NO')
	exit()
one_opened_button_existed = False
for x in a:
	if x == 0:
		if one_opened_button_existed:
			print('NO')
			exit()
		else:
			one_opened_button_existed = True
if one_opened_button_existed:
	print('YES')
else:
	print('NO')


n = int(input())
nlist = list(map(int, input().split()))
if n == 1 and 1 in nlist:
	print('YES')
elif n > 1 and nlist.count(0) == 1:
	print('YES')
else:
	print('NO')


n = int(input())
a = [int(x) for x in input().split()]
cnt = sum(a)
print('YES' if n == 1 and cnt == 1 or (n > 1 and cnt == n - 1) else 'NO')


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')


def p1():
	(n, m) = [float(i) for i in input().split('e')]
	if n * 10 ** m == int(n * 10 ** m):
		print(int(n * 10 ** m))
	else:
		print(n * 10 ** m)

def p2():
	n = int(input())
	l = [int(i) for i in input().split()]
	ans = 'YES'
	if n == 1:
		if l.count(0) == 1:
			ans = 'NO'
	elif l.count(0) != 1:
		ans = 'NO'
	print(ans)

def p3():
	(n, m) = [int(i) for i in input().split()]
	k = 0
	m2 = 0
	for j in range(m):
		a = input()
		if a.count('1') == len(a):
			m2 = max(m2, k)
			k = 0
		else:
			k = k + 1
	m2 = max(m2, k)
	print(m2)

def p4():
	(n, m) = [int(i) for i in input().split()]
	t = 0
	l = m
	for i in range(n):
		a = input().split()
		b = int(a[1])
		a = a[0]
		if a == '+':
			l = l + b
		elif l >= b:
			l = l - b
		else:
			t = t + 1
	print(l, t)

def p5():
	(n, m) = [int(i) for i in input().split()]
	l = []
	v = []
	g = []
	for i in range(n):
		s = input()
		l.append(s)
		v.append(s.count('*'))
	for i in range(m):
		t = 0
		for j in range(n):
			if l[j][i] == '*':
				t = t + 1
		g.append(t)
	ans = 'NO'
	c = sum(v)
	for i in range(n):
		for j in range(m):
			t = v[i] + g[j]
			if l[i][j] == '*':
				t = t - 1
			if t == c:
				ans = 'YES'
				(x, y) = (i + 1, j + 1)
				break
		if ans == 'YES':
			break
	print(ans)
	if ans == 'YES':
		print(x, y)
p2()


n = int(input())
arr = list(map(int, input().split()))
cnt = 0
if n == 1:
	if arr[0] == 1:
		print('YES')
	if arr[0] == 0:
		print('NO')
	exit()
for i in range(n):
	if arr[i] == 0:
		cnt += 1
	else:
		continue
if cnt == 1:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
count_1 = a.count(1)
if n == 1:
	if count_1 == n:
		correctly_fasten = True
	else:
		correctly_fasten = False
elif count_1 == n - 1:
	correctly_fasten = True
else:
	correctly_fasten = False
print('YES' if correctly_fasten else 'NO')


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


n = int(input())
li = list(map(int, input().split()))
flag = 0
if n == 1 and li[0] == 0:
	flag = 1
elif n == 1 and li[0] == 1:
	flag = 0
else:
	k = li.count(1)
	if n - k > 1 or n - k == 0:
		flag = 1
if flag == 1:
	print('NO')
else:
	print('YES')


number_button = input('')
value_string = input('')
value_list = value_string.split()
count = 0
for item in value_list:
	if int(item) == 0:
		count += 1
if len(value_list) == 1:
	if count == 0:
		print('YES')
	else:
		print('NO')
elif count == 1:
	print('YES')
else:
	print('NO')


def is_berland_fashioned(N: int, A: list):
	if N == 1:
		return A[0] == 1
	return sum(A) == N - 1
N = int(input().strip(' '))
A = [int(i) for i in input().strip().split()]
print('YES') if is_berland_fashioned(N, A) else print('NO')


buttons = int(input())
fastened = str(input())
number_buttons = int(buttons)
array_fastened = fastened.split()
array_fastened = array_fastened[0:number_buttons]
x = 0
for i in range(len(array_fastened)):
	if int(array_fastened[i]) == 1:
		x += 1
if (x >= 1 and x == len(array_fastened) - 1 or (x == 1 and len(array_fastened))) == 1:
	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 = list(map(int, input().split()))
ans = True
found = False
if n == 1 and a[0] == 0:
	ans = False
i = 0
while i < n and ans:
	if a[i] == 0 and found == True:
		ans = False
	elif a[i] == 0:
		found = True
	i += 1
if ans and (found or n == 1):
	print('YES')
else:
	print('NO')


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


N = int(input())
X = input()
if N == 1:
	print('YES' if X[0] == '1' else 'NO')
	exit()
print('YES' if X.count('0') == 1 else 'NO')


number_of_buttons = int(input())
buttons_display_on_jacket = map(int, input().split())
number_of_no_fastened_buttons = 0
if number_of_buttons == 1:
	for x in buttons_display_on_jacket:
		if x == 1:
			print('YES')
		else:
			print('NO')
else:
	for x in buttons_display_on_jacket:
		if x == 0:
			number_of_no_fastened_buttons += 1
	if number_of_no_fastened_buttons == 0 or number_of_no_fastened_buttons >= 2:
		print('NO')
	else:
		print('YES')


__author__ = 'Alexander'
import sys
nBut = int(sys.stdin.readline())
buttons = sys.stdin.readline()
if nBut == 1:
	if int(buttons) == 1:
		sys.stdout.write('YES')
	else:
		sys.stdout.write('NO')
elif buttons.count('0') == 1:
	sys.stdout.write('YES')
else:
	sys.stdout.write('NO')


def isValid(ar, l):
	if l == 1:
		if ar[0] == 0:
			return False
		else:
			return True
	elif l > 1:
		open = 0
		for i in ar:
			if i == 0:
				open += 1
		return open == 1
n = int(input())
ar = list(map(int, input().split()))
if isValid(ar, n):
	print('YES')
else:
	print('NO')


def solution(n, a):
	if n == 1 and a[0] == 1:
		return 'YES'
	elif n == 1:
		return 'NO'
	if a.count(0) == 1:
		return 'YES'
	else:
		return 'NO'
n = int(input())
a = [int(x) for x in input().split()]
print(solution(n, a))


read = lambda : map(int, input().split())
n = int(input())
a = list(read())
if len(a) == 1:
	f = a == [1]
else:
	f = a.count(0) == 1
print('YES' if f else 'NO')


n = int(input())
s = list(map(int, input().split()))
ans = 'YES' if len(s) > 1 and s.count(0) == 1 else 'YES' if len(s) == 1 and s.count(1) == 1 else 'NO'
print(ans)


n = int(input())
a = [int(x) for x in input().split()]
b = 0
for i in a:
	if i == 0:
		if b:
			print('NO')
			exit(0)
		else:
			b = 1
if b:
	if len(a) > 1:
		print('YES')
	else:
		print('NO')
elif len(a) == 1:
	print('YES')
else:
	print('NO')


n = int(input())
line = str(input()).split()
line = [int(it) for it in line]
if sum(line) == n == 1 or sum(line) + 1 == n > 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())
s = input().split()
if len(s) == 1 and s.count('0') == 1:
	print('NO')
elif len(s) > 1 and s.count('0') != 1:
	print('NO')
else:
	print('YES')


numberOfButton = input()
listOfButton = input()
passed = True
if numberOfButton == '1':
	passed = listOfButton.count('0') == 0
else:
	passed = listOfButton.count('0') == 1
print('YES' if passed else 'NO')


n = int(input())
values = [int(x) for x in input().split()]
s = sum(values)
print('YES' if n == s and n == 1 or (n > 1 and s == n - 1) else 'NO')


n = int(input())
l = list(map(int, input().split()))
if n == 1:
	if l[0] == 1:
		print('YES')
	else:
		print('NO')
else:
	count = 0
	for i in l:
		if i == 0:
			count += 1
	if count == 1:
		print('YES')
	else:
		print('NO')


a = (input(), input())[1].split()
flag = a.count('0') == 1 and len(a) != 1 or a == ['1']
print('YNEOS'[not flag::2])


N = int(input())
l = sum(list(map(int, input().split())))
if N == 1:
	if l == 1:
		print('YES')
	else:
		print('NO')
elif l == N - 1:
	print('YES')
else:
	print('NO')


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')


def is_fastened_right_way(button_list):
	len_list = len(button_list)
	if len_list == 1:
		if button_list[0]:
			return True
		else:
			return False
	else:
		count = 0
		for button in button_list:
			if button == 0:
				count += 1
			if count > 1:
				return False
		else:
			if count == 0:
				return False
			return True
n = int(input())
button_list = list(map(int, input().split()))
if is_fastened_right_way(button_list):
	print('YES')
else:
	print('NO')


q = input()
n = input().split()
if len(n) == 1 and n[0] == '1':
	print('YES')
elif len(n) != 1 and n.count('0') == 1:
	print('YES')
else:
	print('NO')


a = int(input())
b = input()
arr = b.split(' ')
count = 0
for i in range(0, a):
	if int(arr[i]) == 1:
		count += 1
if a == 1:
	if count == 1:
		print('YES')
	else:
		print('NO')
elif count != a - 1:
	print('NO')
else:
	print('YES')


import sys
import math
import bisect

def solve(A):
	n = len(A)
	if n == 1:
		return A[0] == 1
	return sum(A) == n - 1

def main():
	n = int(input())
	A = list(map(int, input().split()))
	if solve(A):
		print('YES')
	else:
		print('NO')
main()


a = int(input())
b = input()

def func(a, b):
	b = b.split()
	b = [int(g) for g in b]
	if a == 1 and sum(b) == 0:
		print('NO')
	elif a == 1 and sum(b) == 1 and (len(b) == 1):
		print('YES')
	elif sum(b) == a - 1 and 1 <= a <= 1000:
		print('YES')
	else:
		print('NO')
func(a, b)


def isFashion(n, number_list):
	count = 0
	if n == 1:
		if number_list[-1] == 1:
			return 'YES'
		else:
			return 'NO'
	for x in number_list:
		if x == 0:
			count = count + 1
		if count == 2:
			return 'NO'
	if count == 1:
		return 'YES'
	else:
		return 'NO'
n = int(input())
number_string = input()
number_list = list(map(int, number_string.split()))
answer = isFashion(n, number_list)
print(answer)


n = int(input())
a = list(map(int, input().split()))
c = 0
flag = True
for i in range(n):
	if a[i] == 0:
		c += 1
if c == 1 and n != 1 or (n == 1 and a[0] == 1):
	print('YES')
else:
	print('NO')


input()
l = list(map(int, input().split()))
print(['YES', 'NO'][len(l) > 1 and sum(l) != len(l) - 1 or (len(l) == 1 and sum(l) != 1)])


import sys
inputarr = []
i = 0
for line in sys.stdin:
	inputarr.append(line)
	i += 1
	if i >= 2:
		break
secondline = inputarr[1]
arr = secondline.replace('\n', '').split(' ')

def a(arr):
	count0 = 0
	if len(arr) == 1:
		if int(arr[0]) == 1:
			return 'YES'
		else:
			return 'NO'
	else:
		for n in range(0, len(arr)):
			if int(arr[n]) == 0:
				count0 += 1
		if count0 == 1:
			return 'YES'
		else:
			return 'NO'
print(a(arr))