One spring day on his way to university Lesha found an array A. Lesha likes to split arrays into several parts. This time Lesha decided to split the array A into several, possibly one, new arrays so that the sum of elements in each of the new arrays is not zero. One more condition is that if we place the new arrays one after another they will form the old array A.

Lesha is tired now so he asked you to split the array. Help Lesha!


-----Input-----

The first line contains single integer n (1 ≤ n ≤ 100) — the number of elements in the array A.

The next line contains n integers a_1, a_2, ..., a_{n} ( - 10^3 ≤ a_{i} ≤ 10^3) — the elements of the array A.


-----Output-----

If it is not possible to split the array A and satisfy all the constraints, print single line containing "NO" (without quotes).

Otherwise in the first line print "YES" (without quotes). In the next line print single integer k — the number of new arrays. In each of the next k lines print two integers l_{i} and r_{i} which denote the subarray A[l_{i}... r_{i}] of the initial array A being the i-th new array. Integers l_{i}, r_{i} should satisfy the following conditions:  l_1 = 1  r_{k} = n  r_{i} + 1 = l_{i} + 1 for each 1 ≤ i < k. 

If there are multiple answers, print any of them.


-----Examples-----
Input
3
1 2 -3

Output
YES
2
1 2
3 3

Input
8
9 -12 3 4 -4 -10 7 3

Output
YES
2
1 2
3 8

Input
1
0

Output
NO

Input
4
1 2 3 -5

Output
YES
4
1 1
2 2
3 3
4 4

Difficulty: EASY
Tags: Greedy algorithms

Implementation

Constructive algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
import sys, math
n = int(input())
array = list(map(int, input().split()))
if array.count(0) == n:
	print('NO')
	sys.exit()
if sum(array) == 0:
	print('YES')
	print(2)
	for i in range(1, n):
		if sum(array[0:i]) != 0 and sum(array[i:]) != 0:
			print(1, i)
			print(i + 1, n)
			sys.exit()
else:
	print('YES')
	print(1)
	print(1, n)


n = int(input())
x = input()
ara = x.split()
a = b = 0
c = -1
for i in range(n):
	a += int(ara[i])
	if int(ara[i]) != 0 and c == -1:
		c = i
if a == 0 and c == -1:
	print('NO\n')
elif a == 0:
	print('YES\n2\n1 ', c + 1, '\n', c + 2, ' ', n, sep='')
else:
	print('YES\n1\n1 ', n, sep='')


from collections import deque
n = int(input())
a = [int(x) for x in input().split()]
rs = deque()
num_nonzero = 0
for (i, x) in enumerate(a):
	if x != 0:
		num_nonzero += 1
		if num_nonzero == 2:
			rs.append(i)
			num_nonzero = 1
else:
	if num_nonzero == 0:
		print('NO')
	else:
		print('YES')
		print(len(rs) + 1)
		l = 1
		while rs:
			r = rs.popleft()
			print(l, r)
			l = r + 1
		print(l, n)


t = int(input())
a = list(map(int, input().split()))
v = True
if sum(a) != 0:
	print('YES')
	print('1')
	print('1 ' + str(len(a)))
	v = False
else:
	sum = 0
	for i in range(0, t):
		sum += a[i]
		if sum != 0:
			print('YES')
			print('2')
			print('1 ' + str(i + 1))
			print(str(i + 2) + ' ' + str(t))
			v = False
			break
if v:
	print('NO')


n = int(input())
l = list(map(int, input().split()))
l1 = [[0, 0] for i in range(n + 1)]
p = -1
t = -1
v = -1
k = 0
y = -1
for i in range(n):
	if l[i] == 0 and t == -1 and (v == -1):
		v = i + 1
	elif l[i] == 0 and t == 1:
		if v != -1 and v < p:
			y = i + 1
		else:
			v = i + 1
	elif l[i] != 0 and t == -1:
		p = i + 1
		t = 1
	elif l[i] != 0 and t == 1:
		if v != -1 and y != -1:
			l1[i][0] = min(v, y)
			l1[i][1] = max(v, y)
		if v != -1 and y == -1:
			l1[i][0] = min(v, p)
			l1[i][1] = max(v, p)
		if v == -1 and y == -1:
			l1[i][0] = p
			l1[i][1] = p
		k = k + 1
		p = i + 1
		v = -1
		y = -1
		t = 1
if p != -1:
	if v != -1 and y != -1:
		l1[i + 1][0] = min(v, y)
		l1[i + 1][1] = max(v, y)
	if v != -1 and y == -1:
		l1[i + 1][0] = min(p, v)
		l1[i + 1][1] = max(p, v)
	if v == -1 and y == -1:
		l1[i + 1][0] = p
		l1[i + 1][1] = p
	k = k + 1
if k >= 1:
	print('YES')
	print(k)
	for i in range(n + 1):
		if sum(l1[i]) != 0:
			print(l1[i][0], l1[i][1])
else:
	print('NO')


n = int(input())
a = [int(x) for x in input().split()]
T = {}

def split_nonzero(a, T, begin, end):
	if begin == end:
		T[begin, end] = []
	elif begin == end - 1:
		if a[begin] == 0:
			T[begin, end] = 'NO'
		else:
			T[begin, end] = [(begin, begin)]
	elif sum(a[begin:end]) != 0:
		T[begin, end] = [(begin, end - 1)]
	else:
		for k in range(end - 1, begin, -1):
			if (begin, k) in T:
				fr = T[begin, k]
			else:
				fr = split_nonzero(a, T, begin, k)
			if fr != 'NO':
				if (k, end) in T:
					sr = T[k, end]
				else:
					sr = split_nonzero(a, T, k, end)
				if sr != 'NO':
					T[begin, end] = [(begin, k - 1)] + sr
					break
		else:
			T[begin, end] = 'NO'
	return T[begin, end]
result = split_nonzero(a, T, 0, len(a))
if result == 'NO':
	print('NO')
else:
	print('YES')
	print(len(result))
	for (i, j) in result:
		print(i + 1, j + 1)


n = int(input())
l = list(map(int, input().split()))
s = sum(l)
x = 0
y = 0
f = 0
if s != 0:
	print('YES')
	print(1)
	print(1, n)
	exit(0)
for i in range(n):
	x += l[i]
	y += s - x
	if x != 0 and y != 0:
		f = 1
		break
if f:
	print('YES')
	print(2)
	print(1, i + 1)
	print(i + 2, n)
else:
	print('NO')


n = int(input())
i = 1
a = list(map(int, input().split()))
if sum(a) != 0:
	print('YES')
	print(1)
	print(1, n)
	exit()
else:
	while i < n:
		if sum(a[:i]) != 0:
			print('YES')
			print(2)
			print(1, i)
			print(i + 1, n)
			exit()
		i += 1
print('NO')


t = int(input())
sin = input()
sin = sin.split(' ')
a = []
for i in sin:
	a.append(int(i))
v = False
for i in a:
	if i != 0:
		v = True
		break
if v == False:
	print('NO')
else:
	n = 0
	res = []
	print('YES')
	sum = 0
	res.append([1, 0])
	idx = 0
	for i in range(t):
		sum += a[i]
		if sum != 0:
			idx = i
			break
	sum = 0
	for i in range(idx, t):
		sum += a[i]
		if sum == 0:
			sum = a[i]
			res[n][1] = i
			res.append([i + 1, 0])
			n += 1
	res[n][1] = t
	print(len(res))
	for i in range(len(res)):
		print('%d %d' % (res[i][0], res[i][1]))


n = int(input())
a = [int(i) for i in input().split()]
if len(a) - a.count(0) < 1:
	print('NO')
elif len(a) - a.count(0) == 1:
	print('YES\n1\n1', len(a))
else:
	print('YES')
	x = 0
	b = [0]
	for i in range(n):
		if a[i] != 0:
			x += 1
			b.append(i + 1)
	print(x)
	for i in range(1, len(b) - 1):
		print(b[i - 1] + 1, b[i])
	print(b[len(b) - 2] + 1, n)


n = int(input())
a = [int(i) for i in input().split()]
sum = 0
sig = False
for i in a:
	sum += i
	if sum != 0:
		sig = True
if sig:
	print('YES')
	if sum != 0:
		print('1\n1', n)
	else:
		sum = 0
		k = 0
		for i in a:
			sum += i
			k += 1
			if sum != 0:
				break
		print('2\n1', k)
		print(k + 1, n)
else:
	print('NO')


n = int(input())
a = [*map(int, input().split())]
if sum(a) != 0:
	print('YES')
	print(1)
	print(1, n)
	quit()
else:
	for i in range(n):
		if sum(a[:i + 1]) != 0 and sum(a[i + 1:]) != 0:
			print('YES')
			print(2)
			print(1, i + 1)
			print(i + 2, n)
			quit()
print('NO')


import io, os
import sys
from atexit import register
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
sys.stdout = io.BytesIO()
register(lambda : os.write(1, sys.stdout.getvalue()))
tokens = []
tokens_next = 0

def nextStr():
	global tokens, tokens_next
	while tokens_next >= len(tokens):
		tokens = input().split()
		tokens_next = 0
	tokens_next += 1
	return tokens[tokens_next - 1]

def nextInt():
	return int(nextStr())

def nextIntArr(n):
	return [nextInt() for i in range(n)]

def print(s, end='\n'):
	sys.stdout.write((str(s) + end).encode())

def split(a):
	accSum = a[0]
	for j in range(1, len(a)):
		if accSum == 0:
			continue
		cur = split(a[j:])
		if cur:
			return [a[:j]] + cur
	return None
n = nextInt()
a = nextIntArr(n)
if sum(a) != 0:
	print('YES')
	print('1')
	print(f'1 {len(a)}')
	exit(0)
nonZero = next((i for i in range(len(a)) if a[i] != 0), len(a))
if nonZero == len(a):
	print('NO')
	exit(0)
print('YES')
print('2')
print(f'1 {nonZero + 1}')
print(f'{nonZero + 2} {len(a)}')


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


import sys
input()
arr = list(map(int, input().split()))
if not any(map(lambda x: x != 0, arr)):
	print('NO')
	sys.exit()
if sum(arr) != 0:
	print('YES')
	print(1)
	print(1, len(arr))
	sys.exit()
left_ptr = 0
left_sum = 0
for i in arr:
	left_sum += i
	if left_sum != 0:
		print('YES')
		print(2)
		print(1, left_ptr + 1)
		print(left_ptr + 2, len(arr))
		break
	left_ptr += 1


def ri():
	return map(int, input().split())
n = int(input())
a = list(ri())
if all([i == 0 for i in a]):
	print('NO')
	exit()
if sum(a) != 0:
	print('YES')
	print(1)
	print(1, n)
	exit()
s = 0
for i in range(n):
	s += a[i]
	if s != 0:
		print('YES')
		print(2)
		print(1, i + 1)
		print(i + 2, n)
		exit()


n = int(input())
arr = list(map(int, input().split()))
if max(arr) == 0 and min(arr) == 0:
	print('NO')
	exit()
res = 0
for i in range(n):
	res += arr[i]
if res != 0:
	print('YES')
	print(1)
	print(1, n)
	exit()
for i in range(n):
	if arr[i] != 0:
		print('YES')
		print(2)
		print(1, i + 1)
		print(i + 2, n)
		break


import math
n = int(input())
p = list(map(int, input().split()))
sm = 0
pos = -1
for i in range(n):
	sm += p[i]
	p[i] = sm
if p[n - 1] != 0:
	print('YES')
	print('1')
	print('1', n)
else:
	for i in range(n - 1):
		if abs(p[i] - p[n - 1]) != 0:
			pos = i
			break
	if pos == -1:
		print('NO')
	else:
		print('YES')
		print('2')
		print('1', pos + 1)
		print(pos + 2, n)


n = int(input())
a = [int(i) for i in input().split()]
if a[0] == 0 and len(set(a)) == 1:
	print('NO')
elif sum(a) != 0:
	print('YES')
	print(1)
	print(1, n)
else:
	print('YES')
	print(2)
	for i in range(n):
		if sum(a[:i + 1]) and sum(a[i + 1:]):
			print(1, i + 1)
			print(i + 2, n)
			break


import sys

def main():
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	if s != 0:
		print('YES')
		print(1)
		print(1, n)
	else:
		s_left = 0
		for i in range(n):
			s_left += a[i]
			s -= a[i]
			if s_left != 0 and s != 0:
				print('YES')
				print(2)
				print(1, i + 1)
				print(i + 2, n)
				break
		else:
			print('NO')
main()


n = int(input())
lst = list(map(int, input().split()))
if sum(lst) != 0:
	print('YES\n1\n1 %d' % n)
else:
	for i in range(1, n):
		if sum(lst[:i]) != 0:
			print('YES\n2\n1 %d\n%d %d' % (i, i + 1, n))
			quit()
	print('NO')


n = input()
a = [int(x) for x in input().split()]
b = [i for (i, x) in enumerate(a) if x]
if b:
	print('YES')
	if sum(a):
		print(1)
		print(1, n)
	else:
		print(2)
		print(1, b[0] + 1)
		print(b[0] + 2, n)
else:
	print('NO')


a = int(input())
z = list(map(int, input().split()))
if z.count(0) == a:
	print('NO')
else:
	print('YES')
	k = sum(z)
	if k != 0:
		print(1)
		print(1, a)
	else:
		for i in range(a):
			k -= z[i]
			if k != 0:
				print(2)
				print(1, i + 1)
				print(i + 2, a)
				break


N = int(input())
a = list(map(int, input().split()))
d = []
for i in range(N):
	if a[i] != 0:
		break
else:
	print('NO')
	exit()
st = 0
for i in range(N):
	if a[i] != 0:
		for j in range(i + 1, N):
			if a[j] != 0:
				d.append((1, j))
				st = j
				break
		else:
			print('YES')
			print(1)
			print(1, N)
			exit()
		break
i = st
while i < N:
	j = i + 1
	while j < N and a[j] == 0:
		j += 1
	d.append((i + 1, j))
	i = j
print('YES')
print(len(d))
for (i, j) in d:
	print(i, j)


n = int(input())
a = list(map(int, input().split()))
x = next((i for (i, ai) in enumerate(a) if ai), None)
if x is None:
	print('NO')
elif sum(a):
	print('YES', 1, '1 {}'.format(n), sep='\n')
else:
	print('YES', 2, '1 {}'.format(x + 1), '{} {}'.format(x + 2, n), sep='\n')


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


class Node:

	def __init__(self, value, num):
		self.value = value
		self.num = num

	def __lt__(self, other):
		return self.value < other.value
nn = 0

def F(inp):
	global nn
	nn += 1
	return Node(int(inp), nn)

def s(a):
	ss = 0
	for el in a:
		ss += el.value
	return ss

def to_set(n):
	f = set()
	for el in n:
		f.add(el.value)
	return f
n = input()
n = sorted(list(map(F, input().split(' '))))
if s(n) != 0:
	print('YES', 1, sep='\n')
	print(1, nn, sep=' ')
elif to_set(n).__len__() == 2:
	print('YES', 2, sep='\n')
	print(1, 1, sep=' ')
	print(2, nn, sep=' ')
elif n[0].value != 0 or n[-1].value != 0:
	f = min(n[0], n[-1], key=lambda x: x.num)
	print('YES', 2, sep='\n')
	print(1, f.num, sep=' ')
	print(f.num + 1, nn, sep=' ')
else:
	print('NO')


import itertools

def split_array(array):
	if len(set(array)) == 1 and 0 in set(array):
		return None
	split_index = list(range(1, len(array)))
	for i in range(len(array)):
		for each_comb in itertools.combinations(split_index, i):
			each_comb = list(each_comb)
			each_comb.insert(0, 0)
			each_comb.insert(len(each_comb), len(array))
			index = []
			arrays = []
			for i in range(len(each_comb) - 1):
				index.append([each_comb[i], each_comb[i + 1]])
				arrays.append(array[each_comb[i]:each_comb[i + 1]])
			if not 0 in [sum(each_arr) for each_arr in arrays]:
				return index
	return None
num = int(input())
array = [int(x.strip()) for x in input().split(' ')]
index = split_array(array)
if index:
	print('YES')
	print(len(index))
	for each in index:
		print('%d %d' % (each[0] + 1, each[1]), end='')
		print()
else:
	print('NO')


n = int(input())
x = input().split()
ind = Sum = 0
sumt = sum((int(z) for z in x))
if sumt != 0:
	print('YES')
	print(1)
	print(1, n)
	exit()
for i in x:
	Sum += int(i)
	ind += 1
	if Sum != 0 and sumt - Sum != 0:
		print('YES')
		print(2)
		print(1, ind)
		print(ind + 1, n)
		exit()
print('NO')


n = int(input())
l = [int(i) for i in input().split()]
ans = chk = 0
if l.count(0) == n:
	print('NO')
elif sum(l):
	print('YES')
	print(1)
	print(1, n)
else:
	for i in range(1, n):
		if sum(l[:i]) and sum(l[i:]):
			print('YES')
			print(2)
			print(1, i)
			print(i + 1, n)
			break


isDebugMode = False
f = None

def getInputString():
	inputString = 'err'
	if isDebugMode:
		global f
		if f == None:
			f = open('input.txt')
		inputString = f.readline()
	else:
		inputString = input()
	return inputString

def log(logValue, logHint=''):
	if isDebugMode == True:
		print(str(logHint) + ': ' + logValue)

def lastPrint(printValue):
	print(printValue)
	exit()
inputString = getInputString()
n = int(inputString)
inputStringArray = getInputString()
inputStringArray = inputStringArray.split(' ')
inputArray = []
for x in inputStringArray:
	inputArray.append(int(x))
arrStartIndexes = []
index = 0
for x in inputArray:
	if x != 0:
		if len(arrStartIndexes) == 0:
			arrStartIndexes.append(0)
		arrStartIndexes.append(index + 1)
	index += 1
if len(arrStartIndexes) > 0:
	arrStartIndexes[-1] = n
n = len(arrStartIndexes)
if n == 0:
	print('NO')
else:
	print('YES')
	print(n - 1)
	for i in range(n - 1):
		print(arrStartIndexes[i] + 1, arrStartIndexes[i + 1])


def main():
	n = input()
	L = [int(x) for x in input().split()]
	(boolean, lists) = solver(L)
	print(boolean)
	if boolean == 'YES':
		print(len(lists))
		for (l, r) in lists:
			print(l, r)

def solver(L):
	if L == [0] * len(L):
		return ('NO', [])
	else:
		start = firstNonZero(L)
		end = lastNonZero(L)
		i = start
		lists = []
		total = sum(L[start:end + 1])
		if total != 0:
			return ('YES', [(1, len(L))])
		else:
			return ('YES', [(1, end), (end + 1, len(L))])

def firstNonZero(L):
	for i in range(len(L)):
		if L[i] != 0:
			return i
	assert False

def lastNonZero(L):
	for i in range(len(L) - 1, -1, -1):
		if L[i] != 0:
			return i
	assert False
main()


n = input()
arr = input()
arr = arr.split(' ')
sum = 0
temp = -1
for (index, i) in enumerate(arr):
	i = int(i)
	sum += i
	if sum != 0 and temp == -1:
		temp = index
if sum != 0:
	print('YES')
	print(1)
	print(1, n)
elif temp != -1:
	print('YES')
	print(2)
	print(1, temp + 1)
	print(temp + 2, n)
else:
	print('NO')


n = int(input())
a = input().split()
ans = 0
(tag, index) = (0, 0)
for i in range(n):
	a[i] = int(a[i])
	ans += a[i]
	if a[i] != 0 and tag == 0:
		tag = 1
		index = i
if ans != 0:
	print('YES\n1\n1 %d\n' % n, end='')
elif tag == 1:
	print('YES\n2\n1 %d\n%d %d\n' % (index + 1, index + 2, n), end='')
else:
	print('NO')


n = int(input())
items = list(map(int, input().split()))
startArr = []
endArr = []
try:
	startIdx = items.index(0)
	if startIdx != 0:
		for idx in range(startIdx):
			startArr.append(idx)
			endArr.append(idx)
	while startIdx < len(items):
		zeroIdx = startIdx
		while zeroIdx < len(items) and items[zeroIdx] == 0:
			zeroIdx += 1
		if zeroIdx == len(items):
			startIdx = len(items)
			if len(startArr) == 0:
				print('NO')
			else:
				endArr[-1] = len(items) - 1
		else:
			startArr.append(startIdx)
			endArr.append(zeroIdx)
			startIdx = zeroIdx + 1
	if len(startArr) > 0:
		print('YES')
		print(len(startArr))
		for idx in range(len(startArr)):
			print(str(startArr[idx] + 1) + ' ' + str(endArr[idx] + 1))
except:
	print('YES')
	print(len(items))
	for idx in range(len(items)):
		print(str(idx + 1) + ' ' + str(idx + 1))


N = int(input())
As = list(map(int, input().split()))
if min(As) == max(As) == 0:
	print('NO')
else:
	print('YES')
	if sum(As) != 0:
		print('1')
		print('{} {}'.format(1, N))
	else:
		Bs = []
		i = 0
		while sum(Bs) == 0:
			Bs.append(As[i])
			i += 1
		print('2')
		print(1, i)
		print(i + 1, N)


n = int(input())
a = [int(i) for i in input().split()]
if sum(a) != 0:
	print('YES')
	print(1)
	print(1, n)
	exit()
if n == 1 or a.count(0) == n:
	print('NO')
	exit()
i = 0
while a[i] == 0:
	i += 1
print('YES')
print(2)
print(1, i + 1)
print(i + 2, n)


from sys import stdin, stdout

def printAnswer(arr):
	if arr:
		stdout.write('YES\n')
		stdout.write(str(len(arr)) + '\n')
		i = 1
		for x in arr:
			out = map(str, (i, i + len(x) - 1))
			i += len(x)
			stdout.write(' '.join(out) + '\n')
	else:
		stdout.write('NO\n')

def main():
	lines = stdin.readlines()
	nums = list(map(int, lines[1].split()))
	if sum(nums) != 0:
		printAnswer([nums])
		return
	for (i, val) in enumerate(nums):
		if val != 0:
			printAnswer([nums[0:i + 1], nums[i + 1:]])
			return
	printAnswer([])
main()


n = int(input())
arr = list(map(int, input().strip().split()))
t = sum(arr)
z = 0
st = 0
for i in range(n - 1, -1, -1):
	t -= arr[i]
	z += arr[i]
	if t != 0 and z != 0:
		st = 1
		print('YES')
		print(2)
		print('1 ' + str(i))
		print(str(i + 1) + ' ' + str(n))
		break
if st == 0:
	if sum(arr) != 0:
		print('YES')
		print(1)
		print('1 ' + str(n))
	else:
		print('NO')


n = int(input())
a = list(map(int, input().split()))
b = []
l = 0
k = 0
for i in range(n):
	if a[i] != 0:
		k += 1
	if k == 2:
		b.append([l + 1, r + 1])
		l = i
		k = 1
	r = i
if k > 0:
	b.append([l + 1, r + 1])
if len(b) > 0:
	print('YES')
	print(len(b))
	for i in b:
		print(' '.join(map(str, i)))
else:
	print('NO')


import sys
import itertools

def input():
	return sys.stdin.readline().rstrip('\r\n')

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

def Num():
	return int(input())
n = Num()
a = List()
if sum(a) != 0:
	print('YES')
	print(1)
	print(1, n)
elif a.count(0) == n:
	print('NO')
elif 0 not in a:
	print('YES')
	print(n)
	for i in range(n):
		print(i + 1, i + 1)
else:
	idx = []
	last = 0
	s = 0
	for i in range(n):
		s += a[i]
		if s != 0:
			idx.append([last + 1, i + 1])
			s = 0
			last = i + 1
		if len(idx) == 1:
			break
	if idx[0][1] != n:
		idx.append([idx[0][1] + 1, n])
	print('YES')
	print(len(idx))
	for i in idx:
		print(*i)


N = int(input())
nums = [int(i) for i in input().split(' ')]
sub = []
start = 0
end = 0
for i in range(N):
	if nums[i] != 0:
		end = i
		sub.append([start, end])
		start = i + 1
if end != N - 1 and len(sub) > 0:
	sub[-1][1] = N - 1
if len(sub) > 0:
	print('YES')
	print(len(sub))
	for s in sub:
		print('%d %d' % (s[0] + 1, s[1] + 1))
else:
	print('NO')


import sys
n = int(input())
array = list(map(int, input().split()))
cnt = 0
ans = []
start = 0
for i in range(n):
	if array[i] != 0:
		ans.append([start + 1, i + 1])
		start = i + 1
		cnt += 1
if cnt == 0:
	print('NO')
	sys.exit()
if array[-1] == 0:
	help = ans.pop()
	ans.append([help[0], len(array)])
print('YES')
print(cnt)
for i in range(len(ans)):
	print(ans[i][0], end=' ')
	print(ans[i][1])


n = int(input())
arr = list(map(int, input().split()))
i = 0
ansarr = []
while i < n:
	countx = 0
	j = i
	while j < n and countx < 2:
		if countx == 1 and arr[j] != 0:
			break
		elif arr[j] != 0:
			countx += 1
		j += 1
	if j == n and countx != 1:
		print('NO')
		exit(0)
	ansarr.append(i + 1)
	ansarr.append(j)
	i = j
print('YES')
print(len(ansarr) // 2)
print(*ansarr)


n = int(input())
input_data = input()
input_data = input_data.split(' ')
arr = [int(i) for i in input_data]
if sum(arr) != 0:
	print('YES\n1\n%d %d' % (1, len(arr)))
else:
	summa = 0
	for i in arr:
		summa += i
		if summa != 0:
			print('YES\n2')
			print('%d %d' % (1, arr.index(i) + 1))
			print('%d %d' % (arr.index(i) + 2, len(arr)))
			break
	else:
		print('NO')


n = int(input())
array = list(map(int, input().split()))
for i in array:
	if i != 0:
		break
else:
	print('NO')
	quit()
print('YES')
if sum(array) != 0:
	print(1)
	print('1 ' + str(len(array)))
else:
	strings = list()
	s = 0
	i = 0
	prev = 1
	while i < len(array):
		s += array[i]
		if s == 0 and array[i] != 0:
			strings.append(str(prev) + ' ' + str(i))
			prev = i + 1
			s = array[i]
		i += 1
	if prev <= len(array):
		strings.append(str(prev) + ' ' + str(len(array)))
	print(len(strings))
	for s in strings:
		print(s)


def allZeroes(arr):
	for i in arr:
		if i != 0:
			return False
	return True

def sumArray(arr):
	summ = 0
	for i in arr:
		summ += i
	return summ

def solve(arr):
	if allZeroes(arr):
		print('NO')
		return
	if sumArray(arr) != 0:
		print('YES')
		print(1)
		print(1, len(arr))
		return
	summ = 0
	for i in range(len(arr)):
		summ += arr[i]
		if summ != 0:
			print('YES')
			print(2)
			print(1, i + 1)
			print(i + 2, len(arr))
			return
n = input()
arr = list(map(int, input().split()))
solve(arr)


def Main(n):
	arr = list(map(int, input().split()))
	if any(arr):
		print('YES')
		if sum(arr):
			print(1)
			print(1, n)
		else:
			for (i, v) in enumerate(arr):
				if v:
					print(2)
					print(1, i + 1)
					print(i + 2, n)
					break
	else:
		print('NO')
n = int(input())
Main(n)


n = int(input())
d = list(map(int, input().split()))
if any(d):
	print('YES')
	if sum(d):
		print(1)
		print(1, n)
	else:
		for (i, v) in enumerate(d):
			if v:
				print(2)
				print(1, i + 1)
				print(i + 2, n)
				break
else:
	print('NO')


n = int(input())
array = list(map(int, input().split()))
i = 0
while i < n and array[i] == 0:
	i += 1
if i >= n:
	print('NO')
else:
	print('YES')
	amount = 0
	for i in range(n):
		if array[i] != 0:
			amount += 1
	print(amount)
	start = 1
	finish = 0
	dp = 0
	for i in range(n):
		if array[i] == 0:
			finish += 1
		else:
			finish += 1
			dp += 1
			if dp == amount:
				finish = n
				print(start, finish)
				break
			print(start, finish)
			start = finish + 1


def num_non_zero(arr):
	res = 0
	for x in arr:
		if x != 0:
			res += 1
	return res

def find_non_zero(arr, find_from):
	while find_from < len(arr):
		if arr[find_from] != 0:
			return find_from
		find_from += 1

def find_two_non_zero(arr):
	one = find_non_zero(arr, 0)
	two = find_non_zero(arr, one + 1)
	return (one, two)

def main():
	input()
	arr = [int(x) for x in input().split()]
	if sum(arr) != 0:
		print('YES')
		print('1')
		print('1', len(arr))
		return
	if num_non_zero(arr) < 2:
		print('NO')
		return
	print('YES')
	print('2')
	(index1, index2) = find_two_non_zero(arr)
	index1 += 1
	index2 += 1
	print('1', index1)
	print(index1 + 1, len(arr))
main()


n = int(input())
A = list(map(int, input().split()))
if sum(A) != 0:
	print('YES')
	print(str(1))
	print(str(1) + ' ' + str(n))
else:
	ind = -1
	for i in range(n):
		if A[i] == 0:
			continue
		else:
			ind = i + 1
			break
	if ind == -1:
		print('NO')
	else:
		print('YES')
		print(2)
		print(str(1) + ' ' + str(ind))
		print(str(ind + 1) + ' ' + str(n))


def ri():
	return map(int, input().split())
n = int(input())
a = list(ri())
if all([i == 0 for i in a]):
	print('NO')
elif sum(a) != 0:
	print('YES')
	print(1)
	print(1, n)
else:
	for i in range(n):
		if a[i] != 0:
			print('YES')
			print(2)
			print(1, i + 1)
			print(i + 2, n)
			break


n = int(input())
a = list(map(int, input().split()))
i = 0
begin = 0
ans = []
if not any(a):
	print('NO')
	exit(0)
while i < n:
	if a[i] == 0:
		i += 1
	else:
		ans.append([begin, i])
		begin = i + 1
		i += 1
if begin != n:
	ans[-1][1] = n - 1
print('YES')
print(len(ans))
for (a, b) in ans:
	print(a + 1, b + 1)


n = int(input())
L = [int(x) for x in input().split()]
s = 0
t = sum(L)
if t != 0:
	print('YES')
	print(1)
	print(1, n)
else:
	for i in range(0, n):
		s += L[i]
		if s != 0:
			print('YES')
			if i < n - 1:
				print(2)
				print(1, i + 1)
				print(i + 2, n)
				break
			else:
				print(1)
				print(1, n)
				break
	else:
		print('NO')


(n, b) = (int(input()), 0)
a = [int(i) for i in input().split()]
if sum(a) != 0:
	print('YES', 1, sep='\n')
	print(1, n)
else:
	for (i, j) in enumerate(a):
		if j != 0:
			b = i + 1
			break
	if b == 0:
		print('NO')
	else:
		print('YES', 2, sep='\n')
		print(1, b)
		print(b + 1, n)


def main():
	QWE = 'trick'
	INF = 10 ** 9 + 9
	import sys, math
	n = int(input())
	a = map(int, input().split(' ', n - 1))
	rez = 0
	b = -1
	k = 1
	for i in a:
		rez += i
		if rez != 0:
			b = k
		k += 1
	if b == -1:
		print('NO')
		return
	print('YES')
	if rez != 0:
		print(1)
		print(1, n)
		return
	print(2)
	print(1, b)
	print(b + 1, n)
main()


n = int(input())
numbers = [int(x) for x in input().split()]
if all((number == 0 for number in numbers)):
	print('NO')
	exit()
elif sum(numbers) != 0:
	print('YES')
	print(1)
	print(1, len(numbers))
else:
	for (i, number) in enumerate(numbers):
		if number != 0:
			print('YES')
			print(2)
			print(1, i + 1)
			print(i + 2, len(numbers))
			exit()


def main():
	n = int(input())
	aa = list(map(int, input().split()))
	(x, y) = (0, sum(aa))
	if y:
		print('YES\n1\n1 %d' % n)
		return
	for (i, a) in enumerate(aa, 1):
		x += a
		y -= a
		if x and y:
			print('YES\n2\n1 %d\n%d %d' % (i, i + 1, n))
			return
	print('NO')
main()


n = int(input())
A = list(map(int, input().split()))
per = 0
sums = 0
last = 0
answer = []
l = 0
for j in range(n):
	if A[j] != 0:
		per = 1
		last = j
if per == 0:
	print('NO')
else:
	print('YES')
	for j in range(n):
		if A[j] != 0:
			if j != last:
				answer.append([l + 1, j + 1])
				l = j + 1
			else:
				answer.append([l + 1, n])
				break
	print(len(answer))
	for j in answer:
		print(' '.join(map(str, j)))


n = int(input())
l = list(map(int, input().split()))
x = l.count(0)
if x == n:
	print('NO')
elif sum(l) != 0:
	print('YES')
	print(1)
	print(1, n)
else:
	ans = 0
	print('YES')
	for i in range(n):
		ans += l[i]
		if ans != 0:
			break
	print(2)
	print(1, i + 1)
	print(i + 2, n)


n = int(input())
line = list(map(int, input().split()))
v = sum(line)
if v != 0:
	print('YES')
	print(1)
	print('1 ' + str(n))
else:
	x = 0
	for i in range(n):
		if line[i] != 0:
			x = i + 1
			break
	if x > 0:
		print('YES')
		print(2)
		print('1 ' + str(x))
		print(str(x + 1) + ' ' + str(n))
	else:
		print('NO')


n = int(input())
arr = list(map(int, input().split()))
sm = sum(arr)
if sm != 0:
	print('YES')
	print(1)
	print(1, n)
else:
	sm = 0
	done = False
	for i in range(n):
		sm += arr[i]
		if sm != 0:
			print('YES')
			print(2)
			print(1, i + 1)
			print(i + 2, n)
			done = True
			break
	if not done:
		print('NO')


x = int(input())
l_i = list(map(int, input().split()))
l_s = list()
c_l = list()
c_s = 0
c_l.append(1)
for i in range(len(l_i)):
	if l_i[i] + c_s == 0:
		if len(c_l) != 0 and c_s != 0:
			c_l.append(i)
			l_s.append(c_l)
			c_l = list()
			c_l.append(i + 1)
			c_s = 0
	c_s += l_i[i]
c_l.append(len(l_i))
l_s.append(c_l)
if c_s == 0 and len(c_l) != 0:
	print('NO')
else:
	print('YES')
	print(len(l_s))
	for l in l_s:
		print(' '.join((str(x) for x in l)))


n = int(input())
ar = list(map(int, input().split()))
s = 1
summ = 0
su = 0
ans = []
fl = False
f = False
for i in range(n):
	summ += ar[i]
	su += ar[i]
	if su == 0 and f:
		ans.append([s, i])
		s = i + 1
		f = False
		su += ar[i]
	if ar[i] != 0:
		fl = True
		f = True
ans.append([s, n])
if fl == False:
	print('NO')
else:
	print('YES')
	print(len(ans))
	for i in ans:
		print(i[0], i[1])


n = int(input())
a = list(map(int, input().split()))
s = 0
q = False
for i in a:
	s += i
	if i != 0:
		q = True
if s == 0:
	if q:
		b = []
		k = 0
		for i in a:
			k += 1
			b.append(i)
			if i != 0:
				break
		print('YES')
		print(2)
		print(1, k)
		print(k + 1, n)
		print
	else:
		print('NO')
else:
	print('YES')
	print(1)
	print(1, n)


h = int(input())
a = list(map(int, input().split()))
ans = []
p = 1
v = 1
if sum(a) != 0:
	print('YES')
	print(1)
	print(1, len(a))
elif a.count(0) == 0:
	print('YES')
	print(len(a))
	for i in range(1, len(a) + 1):
		print(i, i)
elif a.count(0) == len(a):
	print('NO')
else:
	print('YES')
	n = 0
	for j in range(0, len(a)):
		if a[j] == 0:
			n += 1
		if a[j] != 0:
			ans += [p, v + n]
			n = 0
			v = j + 1
			p = j + 1
		if sum(a[v:]) != 0:
			ans += [v + 1, len(a)]
			print(len(ans) // 2)
			break
	for e in range(0, len(ans), 2):
		print(ans[e], ans[e + 1])


from collections import deque
queue = deque()
n = int(input())
a = list(map(int, input().split()))
for i in range(0, n):
	queue.append((i, i, a[i]))
for i in range(0, n):
	if len(queue) == 0:
		break
	x = queue.popleft()
	if x[2] != 0:
		queue.append(x)
	else:
		while queue:
			y = queue.pop()
			if y[1] == n - 1:
				queue.append(y)
				break
			if y[2] != 0:
				queue.append((y[0], x[1], y[2]))
				flag = True
				break
for i in range(0, n):
	if len(queue) == 0:
		break
	x = queue.pop()
	if x[2] != 0:
		queue.appendleft(x)
	else:
		while queue:
			y = queue.popleft()
			if y[1] == 0:
				queue.append(y)
				break
			if y[2] != 0:
				queue.append((x[0], y[1], y[2]))
				break
if len(queue) == 0:
	print('NO')
else:
	print('YES')
	print(len(queue))
	ans = sorted(queue)
	ans[0] = list(ans[0])
	ans[-1] = list(ans[-1])
	ans[0][0] = 0
	ans[-1][1] = n - 1
	for (x, y, z) in ans:
		print('{} {}'.format(x + 1, y + 1))


N = int(input())
if N > 0:
	a = list(map(int, input().strip().split()))
else:
	print('NO')
if all([x == 0 for x in a]):
	print('NO')
elif sum(a) != 0:
	print('YES')
	print(1)
	print('1 ' + str(len(a)))
else:
	i = 1
	while sum(a[:i]) == 0:
		i += 1
	print('YES')
	print(2)
	print('1 ' + str(i))
	print(str(i + 1) + ' ' + str(len(a)))


n = int(input())
l = list(map(int, input().split()))
zero = 0
for i in l:
	if i == 0:
		zero += 1
if zero == n:
	print('NO')
	exit(0)
print('YES')
ans = []
i = 0
while l[i] == 0:
	i += 1
ans.append([0, i])
i += 1
while i < n:
	if l[i] == 0:
		_l = ans[len(ans) - 1]
		del ans[len(ans) - 1]
		_l[1] = i
		ans.append(_l)
	else:
		ans.append([i, i])
	i += 1
print(len(ans))
for i in ans:
	print(i[0] + 1, i[1] + 1)


n = int(input())
a = [int(i) for i in input().split()]
if all((i == 0 for i in a)):
	print('NO')
	exit()
if sum(a) != 0:
	print('YES')
	print(1)
	print(1, n)
else:
	s = 0
	for i in range(n):
		s += a[i]
		if s != 0:
			print('YES')
			print(2)
			print(1, i + 1)
			print(i + 2, n)
			exit()


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
n = ii()
l = il()
if all((i == 0 for i in l)):
	exit(print('NO'))
l1 = []
sm = 0
for i in range(n):
	if l1 == []:
		l1.append([i + 1])
	elif l[i] == 0 and l1 != []:
		l1[-1].append(i + 1)
	elif l[i] != 0:
		if sum((l[i - 1] for i in l1[-1])) + l[i] == 0:
			l1.append([i + 1])
		elif sum((l[i - 1] for i in l1[-1])) == 0:
			l1[-1].append(i + 1)
		else:
			l1[-1].append(i + 1)
print('YES')
print(len(l1))
for i in l1:
	if len(i) == 1:
		print(i[0], i[0])
	else:
		print(i[0], i[-1])


n = int(input())
arr = list(map(int, input().split()))
s = arr[0]
l = 0
st = []
for i in range(1, n):
	if s != 0 and arr[i] + s == 0:
		st.append((l + 1, i))
		l = i
		s = 0
	s += arr[i]
st.append((l + 1, n))
if sum(arr[st[-1][0] - 1:st[-1][1]]):
	print('YES')
	print(len(st))
	for i in st:
		print(i[0], i[1])
else:
	print('NO')


n = int(input())
l = list(map(int, input().split()))
if set(l) == {0}:
	print('NO')
else:
	print('YES')
	if sum(l) != 0:
		print(1)
		print(1, n)
	else:
		for i in range(1, n):
			if sum(l[:i]) != 0:
				print(2)
				print(1, i)
				print(i + 1, n)
				break


n = int(input())
A = list(map(int, input().split()))
sumA = sum(A)
if sumA:
	print('YES')
	print(1)
	print(1, n)
	exit()
for x in range(n):
	sumA -= A[x]
	if sumA:
		print('YES')
		print(2)
		print(1, x + 1)
		print(x + 2, n)
		break
else:
	print('NO')


int(input())
n = [int(x) for x in input().split()]
i = len(n)
if sum(n) == 0:
	while i > 0:
		if sum(n[:i - 1]) != 0 and sum(n[i - 1:len(n)]) != 0:
			print('YES')
			print('2')
			print('1', i - 1)
			print(i, len(n))
			break
		i -= 1
	else:
		print('NO')
else:
	print('YES')
	print('1')
	print('1', len(n))


def gen(l, r):
	global ans
	if sum(a[l - 1:r]):
		ans += [[l, r]]
		return
	if r == l:
		fail()
	for i in range(l, r):
		if a[i - 1]:
			gen(l, i)
			gen(i + 1, r)
			return
	fail()

def fail():
	print('NO')
	quit()
n = int(input())
a = list(map(int, input().split()))
ans = []
gen(1, n)
ans.sort()
print('YES')
print(len(ans))
for (l, r) in ans:
	print(l, r)


n = int(input())
a = [int(x) for x in input().split()]
res = []
s = a[0]
prev = 0
for i in range(1, len(a)):
	if s == 0:
		s += a[i]
	elif s + a[i] == 0:
		res.append((prev, i - 1))
		s = a[i]
		prev = i
	else:
		s += a[i]
res.append((prev, n - 1))
if s == 0:
	print('NO')
else:
	print('YES')
	print(len(res))
	for (i, j) in res:
		print(i + 1, j + 1)


n = int(input())
l = list(map(int, input().split()))
cnt = 0
for i in l:
	cnt += i == 0
if cnt == n:
	print('NO')
else:
	d = []
	p = 0
	c = -1
	if l[-1] == 0:
		while p < n:
			f = c + 1
			while p < n and l[p] == 0:
				p += 1
			if p == n:
				d[-1][1] = n - 1
			else:
				d += [[f, p]]
			c = p
			p += 1
	else:
		while p < n:
			f = c + 1
			while p < n and l[p] == 0:
				p += 1
			d += [[f, p]]
			c = p
			p += 1
	print('YES')
	print(len(d))
	for i in d:
		print(i[0] + 1, i[1] + 1)


n = int(input())
arr = list(map(int, input().split()))
l = 0
r = len(arr) - 1
res = 'NO'
if sum(arr[l:r + 1]) != 0:
	res = 'YES'
	print(res)
	print(1)
	print(str(l + 1) + ' ' + str(r + 1))
else:
	for l in range(0, r):
		if sum(arr[0:l + 1]) != 0 and sum(arr[l + 1:r + 1]) != 0:
			res = 'YES'
			print(res)
			print(2)
			print(str(1) + ' ' + str(l + 1))
			print(str(l + 2) + ' ' + str(r + 1))
			break
if res == 'NO':
	print(res)


n = int(input())
a = list(map(int, input().split()))
sum = 0
for x in a:
	sum += x
if sum != 0:
	print('YES')
	print('1')
	print(' '.join(map(str, [1, n])))
	exit(0)
else:
	tot = 0
	for i in range(n):
		tot += a[i]
		if tot != 0:
			print('YES')
			res = []
			res.append([1, i + 1])
			res.append([i + 2, n])
			print(len(res))
			for x in res:
				print(' '.join(map(str, x)))
			exit(0)
print('NO')


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


n = int(input())
a = list(map(int, input().split()))
possible = False
if sum(a):
	print('YES')
	print(1)
	print(1, n)
	possible = True
else:
	for (i, x) in enumerate(a):
		if x:
			print('YES')
			print(2)
			print(1, i + 1)
			print(i + 2, n)
			possible = True
			break
if not possible:
	print('NO')


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


from sys import stdin, stdout
n = int(stdin.readline())
values = list(map(int, stdin.readline().split()))
cnt = [values[0]]
for i in range(1, n):
	cnt.append(cnt[-1] + values[i])
if values.count(0) == n:
	stdout.write('NO')
elif cnt[-1]:
	stdout.write('YES\n1\n1 ' + str(n))
else:
	for i in range(n):
		if values[i]:
			m = i + 1
			break
	stdout.write('YES\n2\n1 ' + str(m) + '\n' + str(m + 1) + ' ' + str(n))


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


import sys
n = sys.stdin.readline()
n = int(n)
A = sys.stdin.readline().split(' ')
A = [i.strip() for i in A]
A = [int(i) for i in A]
if 0 not in A:
	print('YES')
	print(n)
	for i in range(0, n):
		print(i + 1, i + 1)
	exit()
elif sum(A) != 0:
	print('YES')
	print('1')
	print('1', n)
	exit()
elif sum(A) == 0:
	for i in range(0, n):
		if sum(A[0:i]) != 0:
			print('YES')
			print('2')
			print('1', i)
			print(i + 1, n)
			exit()
	print('NO')
else:
	print('NO')


import sys, math
n = int(input())
array = list(map(int, input().split()))
if array.count(0) == n:
	print('NO')
	sys.exit()
if sum(array) == 0:
	print('YES')
	print(2)
	i = 1
	while sum(array[0:i]) == 0 or sum(array[i:]) == 0:
		i += 1
	print(1, i)
	print(i + 1, n)
else:
	print('YES')
	print(1)
	print(1, n)


import sys
n = int(input())
a = [int(x) for x in input().split()]
if all((x == 0 for x in a)):
	print('NO')
	sys.exit(0)
if sum(a) != 0:
	print('YES\n1\n1', n)
	sys.exit(0)
for i in range(1, n):
	if sum(a[:i]) != 0 and sum(a[i:]) != 0:
		print('YES\n2')
		print(1, i)
		print(i + 1, n)
		sys.exit(0)


n = int(input())
a = list(map(int, input().rstrip().split()))
i = 0
li = []
l = 1
s = 0
if a.count(0) == n:
	print('NO')
	exit()
while i < n:
	if s + a[i] != 0:
		s += a[i]
		i += 1
	elif s + a[i] == 0 and a[i] != 0:
		li += [[l, i]]
		l = i + 1
		s = a[i]
		i += 1
	else:
		i += 1
li.append([l, n])
print('YES')
print(len(li))
for x in li:
	print(*x)


import sys
import math
import bisect

def solve(A):
	B = []
	n = len(A)
	s = set(A)
	if len(s) == 1 and 0 in s:
		return None
	if sum(A) != 0:
		B.append([0, n - 1])
		return B
	val = 0
	for i in range(n):
		val += A[i]
		if val != 0:
			B.append([0, i])
			B.append([i + 1, n - 1])
			break
	return B

def main():
	n = int(input())
	A = list(map(int, input().split()))
	B = solve(A)
	if B == None:
		print('NO')
	else:
		print('YES')
		print(len(B))
		for i in range(len(B)):
			print(' '.join(list((str(a + 1) for a in B[i]))))
main()


length = int(input())
num = [int(n) for n in input().split(' ')]
newarray = []
oldindex = 1
dispsum = float('-inf')
for n in range(length):
	if dispsum == float('-inf'):
		dispsum = num[n]
	elif num[n] + dispsum == 0 and (num[n] != 0 and dispsum != 0):
		newarray.append(str(oldindex) + ' ' + str(n))
		oldindex = n + 1
		dispsum = num[n]
	else:
		dispsum += num[n]
else:
	if dispsum == 0:
		print('NO')
	else:
		newarray.append(str(oldindex) + ' ' + str(length))
		print('YES')
		print(len(newarray))
		for n in newarray:
			print(n)


n = int(input())
a = list(map(int, input().split()))
ans = []
s = 1
x = 0
while x < len(a):
	while x < len(a) and a[x] == 0:
		x += 1
	if x == len(a):
		if len(ans) > 0:
			ans[-1][1] = x
		break
	ans.append([s, x + 1])
	x += 1
	s = x + 1
if len(ans) == 0:
	print('NO')
elif len(ans) == 1:
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		print(1)
		print(1, n)
else:
	print('YES')
	print(len(ans))
	for v in ans:
		print(*v)


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

def solve():
	i = get_first(arr)
	if i is None:
		print('NO')
		return
	tail = arr[i + 1:]
	if not len(tail):
		print('YES')
		print('1')
		print('1 {}'.format(str(len(arr))))
		return
	s = sum(tail)
	if s:
		print('YES')
		print('2')
		print('1', i + 1)
		print(i + 2, len(arr), sep=' ')
		return
	print('YES')
	print('1')
	print('1 {}'.format(str(len(arr))))
	return

def get_first(arr):
	for (i, num) in enumerate(arr):
		if num != 0:
			return i
	return None
solve()


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

def main(A, n):
	splits = [[0, n - 1]]
	if sum(A) != 0:
		k = 1
		splits = [[0, n - 1]]
		return (True, k, splits)
	elif A.count(0) == n:
		return (False, None, None)
	count = n - 1
	while sum(A[count:]) == 0:
		count -= 1
	k = 2
	splits[0][1] = count - 1
	splits.append([count, n - 1])
	return (True, k, splits)
(valid, k, splits) = main(A, n)
if valid:
	print('YES')
	print(k)
	for s in splits:
		print(' '.join([str(i + 1) for i in s]))
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
if list(set(a)) == [0]:
	print('NO')
elif sum(a) != 0:
	print('YES')
	print(1)
	print(1, n)
else:
	for x in range(n):
		if sum(a[:x + 1]) != 0 and sum(a[x + 1:]) != 0:
			print('YES')
			print(2)
			print(1, x + 1)
			print(x + 2, n)
			break


import sys
k = int(input())
l = []
l = input().split(' ')
s = 0
p = []
i = 0
ok = 0
while i < k:
	if int(l[i]) != 0:
		p.append(str(i + 1) + ' ')
		p.append(str(i + 1) + '\n')
		s += 1
	else:
		som = 0
		res = i
		for j in range(i + 1, k):
			som += int(l[j])
			i += 1
			if som != 0:
				break
		if som != 0:
			s += 1
			p.append(str(res + 1) + ' ')
			p.append(str(i + 1) + '\n')
		elif s != 0:
			ok = 1
			print('YES')
			print(s)
			sys.stdout.write(''.join(p[:2 * s - 2]))
			sys.stdout.write(p[2 * s - 2])
			sys.stdout.write(str(k))
		else:
			ok = 1
			print('NO')
	i += 1
if s == 0 and ok == 0:
	print('NO')
elif ok == 0:
	print('YES')
	print(s)
	print(''.join(p))


def check_zero(ar):
	for i in range(n):
		if ar[i] != 0:
			return False
	return True
n = int(input())
ls = list(map(int, input().split()))
sm = sum(ls)
if sm:
	print('YES')
	print(1)
	print(1, n)
elif check_zero(ls):
	print('NO')
else:
	tsm = 0
	for i in range(n):
		tsm += ls[i]
		if tsm != 0:
			print('YES')
			print(2)
			print(1, i + 1)
			print(i + 2, n)
			break


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

def solve(array, n):
	if sum(array) != 0:
		return [(0, n - 1)]
	for border in range(n - 1):
		left = array[0:border + 1]
		right = array[border + 1:n]
		if sum(left) != 0 and sum(right) != 0:
			return [(0, border), (border + 1, n - 1)]
	return None

def main():
	n = int(input())
	array = list_from_input()
	intervals = solve(array, n)
	if intervals is None:
		print('NO')
	else:
		print('YES')
		print(len(intervals))
		for (l, r) in intervals:
			print('{0} {1}'.format(l + 1, r + 1))
main()


n = int(input())
A = list(map(int, input().split()))
found = False
if sum(A) != 0:
	print('YES')
	print('1')
	print('1 ' + str(len(A)))
	found = True
else:
	for i in range(len(A)):
		if sum(A[:i]) != 0 and sum(A[i:]) != 0:
			print('YES')
			print('2')
			print('1 ' + str(i))
			print(str(i + 1) + ' ' + str(len(A)))
			found = True
			break
if not found:
	print('NO')


__author__ = 'yiyi'
n = int(input())
arr = input().split()
sum = 0
sum1 = 0
flag = True
idx = -1
c = 0
for i in arr:
	j = int(i)
	sum += j
for i in arr:
	j = int(i)
	sum1 += j
	if idx == -1 and sum1 != 0 and (sum - sum1 != 0):
		idx = c
	c += 1
if sum != 0 or idx == n - 1:
	print('YES\n1\n1 %d' % n)
elif idx == -1:
	print('NO')
	exit()
else:
	print('YES\n2')
	print(1, idx + 1)
	print(idx + 2, n)


n = int(input())
t = list(map(int, input().split()))
if t.count(0) == n:
	print('NO')
elif sum(t) != 0:
	print('YES')
	print(1)
	print(1, n)
else:
	f = []
	u = 0
	for j in range(n):
		u += t[j]
		if u != 0:
			print('YES')
			print(2)
			print(1, j + 1)
			print(j + 2, n)
			break


import itertools

def solve(A):
	B = list(itertools.accumulate(A))
	if B[-1] != 0:
		return [(1, len(A))]
	else:
		for (i, b) in enumerate(B):
			if b != 0:
				return [(1, i + 1), (i + 2, len(A))]
		return None
n = int(input())
A = [int(x) for x in input().split()]
borders = solve(A)
if borders is None:
	print('NO')
else:
	print('YES')
	print(len(borders))
	for p in borders:
		print(p[0], p[1])


n = int(input())
a = list(map(int, input().split()))
ans = True
an = []
c = 0
for i in range(len(a)):
	if a[i] != 0:
		an.append([c + 1, i + 1])
		c = i + 1
if len(an) and a[-1] == 0:
	h = an.pop()
	an.append([h[0], n])
if len(an):
	print('YES')
	print(len(an))
	for e in an:
		print(*e)
else:
	print('NO')


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


from math import *
from sys import *
from decimal import *

def gcd(a, b):
	if b:
		return gcd(b, a % b)
	return a
n = int(input())
arr = [int(z) for z in input().split()]
fst = [0]
for i in range(n):
	if arr[i]:
		fst.append(i + 1)
fst.pop()
fst.append(n)
if len(fst) >= 2:
	print('YES')
	print(len(fst) - 1)
	for i in range(len(fst) - 1):
		print(fst[i] + 1, fst[i + 1])
else:
	print('NO')


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


def p3(a, start, sol):
	if not a:
		return 6
	if sum(a) != 0:
		sol.append([1 + start, len(a) + start])
		return sol
	for (i, n) in enumerate(a):
		if sum(a[:i]) != 0:
			sol.append([1 + start, i + start])
			sol = p3(a[i:], start + i, sol)
			return sol
n = input()
a = [int(i) for i in input().split(' ')]
sol = p3(a, 0, [])
if not sol:
	print('NO')
else:
	print('YES')
	print(len(sol))
	for b in sol:
		print(' '.join([str(i) for i in b]))


n = int(input())
arr = list(map(int, input().split()))
ans = []
if sum(arr) != 0:
	print('YES')
	print(1)
	print(1, n)
else:
	i = 0
	while i < len(arr) and arr[i] == 0:
		i += 1
	if i == len(arr):
		print('NO')
	else:
		print('YES')
		print(2)
		print(1, i + 1)
		print(i + 2, n)


n = int(input())
A = [int(i) for i in input().split()]
if sum(A) != 0:
	print('YES')
	print(1)
	print(1, n)
elif set(A) == {0}:
	print('NO')
else:
	for (i, a) in enumerate(A):
		if a != 0:
			r_1 = i + 1
			l_2 = i + 2
			break
	print('YES')
	print(2)
	print(1, r_1)
	print(l_2, n)


from collections import Counter
n = int(input())
arr = list(map(lambda x: int(x), input().split()))
if len(Counter(arr)) == 1 and 0 in Counter(arr):
	print('NO')
elif sum(arr) != 0:
	print('YES')
	print('1')
	res = [str(1), str(n)]
	print(' '.join(res))
else:
	su = 0
	for i in range(len(arr)):
		su += arr[i]
		if su != 0:
			print('YES')
			res1 = [str(1), str(i + 1)]
			res2 = [str(i + 2), str(n)]
			print('2')
			print(' '.join(res1))
			print(' '.join(res2))
			break


def do():
	n = int(input())
	ar = list(map(int, input().split()))
	if sum(ar) != 0:
		print('YES')
		print(1)
		print(1, n)
		return
	cur = 0
	for i in range(n - 1):
		cur += ar[i]
		if cur != 0:
			print('YES')
			print(2)
			print(1, i + 1)
			print(i + 2, n)
			return
	print('NO')
	return
do()


IL = lambda : list(map(int, input().split()))
IS = lambda : input().split()
I = lambda : int(input())
S = lambda : input()
n = I()
a = IL()
if a.count(0) == n:
	print('NO')
else:
	print('YES')
	print(n - a.count(0))
	while a:
		group = []
		gmin = n - len(a) + 1
		while sum(group) == 0:
			group.append(a.pop(0))
		if a.count(0) == len(a):
			group += a
			a = []
		gmax = gmin + len(group) - 1
		print(gmin, gmax)


n = int(input())
a = [x for x in map(int, input().split())]
if sum(a) != 0:
	print('YES\n1\n1 %d' % n)
else:
	ok = False
	for i in range(1, n):
		if sum(a[i:]) != 0:
			ok = True
			print('YES\n2\n1 %d\n%d %d' % (i, i + 1, n))
			break
	if not ok:
		print('NO')


def split_array(arr):
	prefs = list()
	sum_acc = 0
	for i in arr:
		sum_acc += i
		prefs.append(sum_acc)
	if sum_acc != 0:
		return ((1, len(arr)),)
	for i in range(len(arr) - 1, -1, -1):
		if prefs[i] != 0 and sum_acc - prefs[i] != 0:
			return ((1, i + 1), (i + 2, len(arr)))
	return ()

def main():
	line2 = input()
	line2 = input()
	v = split_array([int(i) for i in line2.split(' ')])
	if len(v) == 0:
		print('NO')
	elif len(v) == 1:
		print('YES\n1')
		print(v[0][0], v[0][1])
	else:
		print('YES\n2')
		print(v[0][0], v[0][1])
		print(v[1][0], v[1][1])
main()


N = int(input())
A = [int(x) for x in input().split()]
if all((A[i] == 0 for i in range(N))):
	print('NO')
else:
	print('YES')
	ans = []
	(nz_l, nz_r) = (0, N - 1)
	while A[nz_l] == 0:
		nz_l += 1
	while A[nz_r] == 0:
		nz_r -= 1
	now = nz_l
	while now <= nz_r:
		total = 0
		for i in range(now, N):
			total += A[i]
			if A[i] != 0:
				ans.append([now, i])
				now = i + 1
				break
	ans[0][0] = 0
	ans[-1][1] = N - 1
	print(len(ans))
	for (l, r) in ans:
		print(l + 1, r + 1)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans
n = int(input())
array = list(map(int, input().split()))
if sum(array) == 0:
	if array.count(0) == n:
		print('NO')
	else:
		for i in range(1, n):
			array[i] += array[i - 1]
		for i in range(n):
			if array[i] != 0:
				index = i
		print('YES')
		if n == 1:
			print(1)
			print('1 1')
		else:
			print(2)
			print('1', index + 1)
			print(index + 2, n)
else:
	print('YES')
	print(1)
	print(1, n)


n = int(input())
a = [i for i in map(int, input().split(' '))]
if sum(a) != 0:
	print('YES')
	print(1)
	print(1, n)
elif a == [0] * len(a):
	print('NO')
else:
	print('YES')
	c = 0
	i = 0
	while c == 0:
		c += a[i]
		i += 1
	print(2)
	print(1, i)
	print(i + 1, n)


n = int(input())
lst = list(map(int, input().strip().split(' ')))
if sum(lst) != 0:
	print('YES')
	print(1)
	print(1, n, end=' ')
elif lst.count(0) == n:
	print('NO')
elif lst.count(0) == 0:
	print('YES')
	print(n)
	for j in range(n):
		print(j + 1, j + 1, end=' ')
		print()
else:
	print('YES')
	print(2)
	for j in range(n):
		if sum(lst[:j]) != 0 and sum(lst[j:]) != 0:
			print(1, j, end=' ')
			print()
			print(j + 1, n, end=' ')
			print()
			break


n = int(input())
a = [int(x) for x in input().split()]
s = sum(a)
if s != 0:
	print('YES')
	print(1)
	print(1, n)
elif a[0] != 0:
	print('YES')
	print(2)
	print(1, 1)
	print(2, n)
else:
	j = 0
	while a[j] == 0:
		j += 1
		if j == n:
			break
	if j == n:
		print('NO')
	else:
		print('YES')
		print(2)
		print(1, j + 1)
		print(j + 2, n)


n = int(input())
a = [int(x) for x in input().split()]
rs = []
num_nonzero = 0
for (i, x) in enumerate(a):
	if x != 0:
		num_nonzero += 1
		if num_nonzero == 2:
			rs.append(i)
			num_nonzero = 1
else:
	if num_nonzero == 0:
		print('NO')
	else:
		print('YES')
		print(len(rs) + 1)
		l = 1
		for r in rs:
			print(l, r)
			l = r + 1
		print(l, n)


n = int(input())
line = list(map(int, input().split()))
if max(sorted(line)) == 0 and min(sorted(line)) == 0:
	print('NO')
else:
	s = 0
	for i in range(n):
		s += line[i]
	if s != 0:
		print('YES')
		print(1)
		print(1, n)
	else:
		for i in range(n):
			if line[i] != 0:
				print('YES')
				print(2)
				print(1, i + 1)
				print(i + 2, n)
				break


n = int(input())
l = list(map(int, input().split()))
if all((i == 0 for i in l)):
	print('NO')
	exit()
if sum(l) != 0:
	print('YES')
	print('1')
	print(1, n)
else:
	s = 0
	for i in range(n):
		s += l[i]
		if s != 0:
			print('YES')
			print(2)
			print(1, i + 1)
			print(i + 2, n)
			exit()


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


n = int(input())
arr = list(map(int, input().split()))
sm = sum(arr)
tot = 0
if sm != 0:
	print('YES')
	print(1)
	print(1, n)
	exit()
for i in range(n - 1):
	tot += arr[i]
	if tot != sm:
		print('YES')
		print(2)
		print(1, i + 1)
		print(i + 2, n)
		exit()
print('NO')


n = input()
l = input().split(' ')
l = [int(a) for a in l]
outs = []
start = 1
end = 1
for el in l:
	if el != 0:
		outs += [[start, end]]
		start = end + 1
		end = end + 1
	else:
		end += 1
if start == 1 and end == len(l) + 1:
	print('NO')
else:
	if start != end:
		outs[-1][1] = end - 1
	print('YES')
	print(len(outs))
	for el in outs:
		print(*el)


n = int(input())
a = [int(i) for i in input().split()]
if a.count(0) == n:
	print('NO')
elif sum(a) != 0:
	print('YES', 1, sep='\n')
	print(1, n)
else:
	print('YES', 2, sep='\n')
	for i in range(1, n):
		if sum(a[:i]):
			print(1, i)
			print(i + 1, n)
			break


a = int(input())
t = input().split()
for i in range(a):
	t[i] = int(t[i])
k = 0
for i in range(a):
	if sum(t[0:i + 1]) and sum(t[i + 1:a]):
		print('YES')
		print('2')
		print(1, i + 1)
		print(i + 2, a)
		k = 1
		break
if not k:
	if sum(t):
		print('YES')
		print('1')
		print('1', a)
	else:
		print('NO')


n = int(input())
numbers = list(map(int, input().split()))
if all((numbers[x] == 0 for x in range(n))):
	print('NO')
else:
	print('YES')
	if sum(numbers):
		print('1\n1 {}'.format(n))
	else:
		i = 0
		while sum(numbers[0:i + 1]) == 0:
			i += 1
		print('2\n{} {}\n{} {}'.format(1, i + 1, i + 2, n))


n = int(input())
arr = [int(x) for x in input().split()]
s = 0
q = 0
prev = 0
ans = []
for i in range(n):
	s += arr[i]
	if arr[i] == 0:
		q += 1
	if s != 0:
		ans.append([prev, i])
		prev = i + 1
		s = 0
if q == n or len(ans) == s == 0:
	print('NO')
else:
	ans[-1][1] = n - 1
	print('YES')
	print(len(ans))
	for x in ans:
		print(x[0] + 1, x[1] + 1)


n = int(input())
element = list(map(int, input().split()))
sumElement = sum(element)
if sumElement:
	print('YES')
	print(1)
	print(1, n)
	exit()
for x in range(n):
	sumElement -= element[x]
	if sumElement != 0:
		print('YES')
		print(2)
		print(1, x + 1)
		print(x + 2, n)
		break
else:
	print('NO')


def main():
	N = int(input())
	arr = [int(i) for i in input().split()]
	C = [0 for i in range(N + 2)]
	for i in range(N):
		C[i + 1] = C[i] + arr[i]
	a = 0
	b = N
	while a < b:
		if C[b] - C[a] != 0:
			break
		else:
			b -= 1
	if a < b:
		print('YES')
		print('2' if b != N else '1')
		print(a + 1, b)
		if b != N:
			print(b + 1, N)
	else:
		print('NO')
main()


def possible(array):
	return any((x != '0' for x in array))

def arrays(array):
	arrays = list()
	i = 1
	while i <= len(array):
		arrays.append(i)
		while i < len(array) and array[i - 1] == '0':
			i += 1
		while i < len(array) and array[i] == '0':
			i += 1
		arrays[-1] = str(arrays[-1]) + ' ' + str(i)
		i += 1
	return arrays
useless = input()
array = input().split(' ')
if possible(array):
	print('YES')
	print(len(array) - array.count('0'))
	for i in arrays(array):
		print(i)
else:
	print('NO')


n = int(input())
A = list(map(int, input().split()))
if sum(A) != 0:
	print('YES')
	print(1)
	print(1, n)
	exit()
for i in range(1, len(A)):
	sum1 = sum(A[:i])
	sum2 = sum(A[i:])
	if sum1 != 0 and sum2 != 0:
		print('YES')
		print(2)
		print(1, i)
		print(i + 1, n)
		exit()
print('NO')


n = int(input())
a = list(map(int, input().split()))
b = []
o = 0
l = 1
if a[0] == 0:
	f = 0
	for i in range(1, len(a)):
		if a[i] == 0:
			pass
		else:
			if f != 0:
				b += [[l, i]]
				l = i + 1
			f = 1
	if f != 0:
		b += [[l, n]]
else:
	for i in range(1, len(a)):
		if a[i] == 0:
			pass
		else:
			b += [[l, i]]
			l = i + 1
	b += [[l, n]]
if len(b) == 0:
	print('NO')
else:
	print('YES', len(b), sep='\n')
	for i in b:
		print(*i)


n = int(input())
la = list(map(int, input().split()))
lb = [i + 1 for i in range(n) if la[i] != 0]
if len(lb) == 0:
	print('NO')
else:
	lb[-1] = n
	print('YES')
	print(len(lb))
	prev = 0
	for i in range(len(lb)):
		print(' '.join(map(str, [prev + 1, lb[i]])))
		prev = lb[i]


q = int(input())
a = list(map(int, input().split()))
if a.count(0) == q:
	print('NO')
elif sum(a) != 0:
	print('YES')
	print(1)
	print(1, q)
else:
	i = 0
	while a[i] == 0:
		i += 1
	print('YES')
	print(2)
	print(1, i + 1)
	print(i + 2, q)


n = int(input())
a = list(map(int, input().split(' ')))
m = []
s = 0
f = 0
t = 0
for i in range(n):
	if a[i] == 0:
		t += 1
	else:
		m.append([f, t])
		s = 0
		f = i + 1
		t = i + 1
if f != i + 1 and len(m) != 0:
	m[len(m) - 1][1] = i
if len(m) == 0:
	print('NO')
else:
	print('YES')
	print(len(m))
	for el in m:
		print(el[0] + 1, el[1] + 1)


def inp():
	return map(int, input().split())
n = int(input())
l = list(inp())
total = sum(l)
if total != 0:
	print('YES')
	print(1)
	print(f'1 {n}')
	exit(0)
left_total = 0
for (idx, x) in enumerate(l):
	if x != 0:
		print('YES')
		print(2)
		print(f'1 {idx + 1}')
		print(f'{idx + 2} {n}')
		exit(0)
print('NO')


def main():
	n = int(input())
	a = [int(c) for c in input().split()]
	if all((e == 0 for e in a)):
		print('NO')
		return
	if sum(a) != 0:
		print('YES')
		print(1)
		print(1, n)
		return
	for (i, e) in enumerate(a, 1):
		if e != 0:
			print('YES')
			print(2)
			print(1, i)
			print(i + 1, n)
			return
main()


from sys import stdin
n = int(input())
a = [int(x) for x in input().split()]
f = False
for i in range(len(a)):
	if a[i] != 0:
		ln = i
		f = True
		break
if not f:
	print('NO')
else:
	print('YES')
	l = 0
	i = ln + 1
	ans = []
	while i < len(a):
		if a[i] == 0:
			i += 1
		else:
			ans.append((l + 1, i))
			l = i
			i += 1
	if l < len(a):
		ans.append((l + 1, i))
	print(len(ans))
	for i in ans:
		print(i[0], i[1])


import sys

def split_array(A):
	if len(A) == 0:
		return []
	if len(list(filter(lambda a: a == 0, A))) == len(A):
		return []
	sublists = [[A[0]]]
	rolling_sum = A[0]
	for a in A[1:]:
		last_list = sublists[-1]
		if rolling_sum + a == 0 and a != 0:
			sublists.append([a])
			rolling_sum = a
		else:
			last_list.append(a)
			rolling_sum += a
	return sublists

def output(sublists):
	if len(sublists) == 0:
		return 'NO'
	else:
		op = 'YES\n'
		op += str(len(sublists)) + '\n'
		idx = 0
		for sublist in sublists:
			op += str(idx + 1) + ' '
			op += str(idx + len(sublist)) + '\n'
			idx += len(sublist)
		return op

def test():
	test1 = [1, 2, -3]
	test2 = [9, -12, 3, 4, -4, -10, 7, 3]
	test3 = [0]
	print('===== TEST 1 =====')
	a1 = split_array(test1)
	print(a1)
	print(output(a1))
	print('===== TEST 2 =====')
	a2 = split_array(test2)
	print(a2)
	print(output(a2))
	print('===== TEST 3 =====')
	a3 = split_array(test3)
	print(a3)
	print(output(a3))

def main():
	k = int(sys.stdin.readline().strip())
	nums = sys.stdin.readline().strip()
	nums = list(map(int, nums.split()))
	print(output(split_array(nums)))
main()


n = int(input())
l = list(map(int, input().split()))
if l.count(0) == n:
	print('NO')
else:
	s = 0
	t = [1]
	d = []
	for i in range(n):
		s = s + l[i]
		if l[i] != 0 and s == 0:
			t.append(i)
			d.append(t)
			t = [i + 1]
			s = l[i]
	t.append(n)
	d.append(t)
	print('YES')
	print(len(d))
	for i in d:
		print(i[0], i[1])


n = int(input())
arr = [int(x) for x in input().split()]
if sum(arr) == 0:
	for i in range(n):
		if arr[i] != 0:
			print('YES')
			print(2)
			print(1, i + 1)
			print(i + 2, n)
			exit()
			break
	else:
		print('NO')
		exit()
print('YES')
print(1)
print(1, n)


R = lambda : list(map(int, input().split()))
(n, a, s) = (R(), R(), 0)
for x in a:
	s += x
if s:
	print('YES\n1\n1 ' + str(len(a)))
else:
	(p, f) = (0, 0)
	for i in range(len(a)):
		p += a[i]
		if p != 0 and (not f):
			print('YES\n2\n1 %d\n%d %d' % (i + 1, i + 2, len(a)))
			f = 1
	if not f:
		print('NO')


n = int(input())
a = [int(i) for i in input().split()]
import sys
if n == 1:
	print('NO' if a[0] == 0 else 'YES\n1\n1 1')
else:
	sol = []
	start = 0
	for i in range(n):
		if sum(a[start:i + 2]) == 0 and sum(a[start:i + 1]) != 0:
			sol += [(str(start + 1), str(i + 1))]
			start = i + 1
	if sum(a[start:n]) != 0:
		sol += [(str(start + 1), str(n))]
		print('YES')
		print(len(sol))
		for i in sol:
			print(' '.join(i))
	else:
		print('NO')


n = int(input())
l = [int(i) for i in input().split()]
if sum(l) != 0:
	print('YES')
	print(1)
	print(1, n)
	exit()
if l.count(0) == n:
	print('NO')
	exit()
for i in range(n):
	if l[i] != 0:
		index = i + 1
		break
print('YES')
print(2)
print(1, index)
print(index + 1, n)


n = int(input())
numbers = [int(x) for x in input().split(' ')]
total_sum = sum(numbers)
s = 0
i = 0
if total_sum != 0:
	print('YES')
	print(1)
	print(1, n)
	s = 1
else:
	for i in range(n):
		s += numbers[i]
		if s != 0:
			print('YES')
			print(2)
			print(1, i + 1)
			print(i + 2, n)
			break
if s == 0:
	print('NO')


def codeforces(lst):
	start = 1
	result = []
	current_sum = 0
	for (num, item) in enumerate(lst):
		current_sum += item
		if current_sum != 0:
			result.append((start, num + 1))
			current_sum = 0
			start = num + 2
	if result:
		result[-1] = (result[-1][0], len(lst))
	return result
_ = input()
lst = list(map(int, input().split()))
result = codeforces(lst)
if result:
	print('YES')
	print(len(result))
	for (x, y) in result:
		print(x, y)
else:
	print('NO')


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

def final(ans):
	print(len(ans))
	for i in range(len(ans)):
		print(*ans[i])
if a == [0] * n:
	print('NO')
	exit(0)
print('YES')
ans = []
last = -1
for i in range(n):
	if a[i] != 0:
		last = i
		break
if last == n - 1:
	ans.append([1, n])
	final(ans)
	exit()
mmm = -1
for i in range(last + 1, n):
	if a[i] != 0:
		ans.append([1, i])
		mmm = i
		break
if mmm == -1:
	ans.append([1, n])
	final(ans)
	exit()
last = mmm
left = last
right = last + 1
flag = last
while right < n:
	if a[right] != 0:
		ans.append([left + 1, right])
		left = right
		flag = right
	right += 1
if flag != n:
	ans.append([left + 1, n])
final(ans)


n = int(input())
a = list(map(int, input().split()))
zero_cnt = sum([1 for x in a if x == 0])
if zero_cnt == n:
	print('NO')
else:
	print('YES')
	non_zero = n - zero_cnt
	if non_zero is 1:
		print('1')
		print(1, n)
	else:
		cur_cnt = 0
		pairs = []
		l = 0
		for i in range(n):
			if a[i] != 0:
				pairs.append([l, i])
				l = i + 1
		if a[-1] == 0:
			pairs[-1][1] = n - 1
		print(len(pairs))
		for p in pairs:
			print(p[0] + 1, p[1] + 1)


def main():
	i = j = 0
	n = int(input())
	ara = list(map(int, input().split()))
	if any(ara):
		print('YES')
		if sum(ara) != 0:
			print(1)
			print(1, n)
		else:
			for (i, j) in enumerate(ara):
				if j != 0:
					print(2)
					print(1, i + 1)
					print(i + 2, n)
					break
	else:
		print('NO')
main()


n = int(input())
arr = list(map(int, input().split()))
if len(set(arr)) == 1 and arr[0] == 0:
	print('NO')
	exit()
if sum(arr) != 0:
	print('YES')
	print(1)
	print(1, n)
else:
	sm = 0
	a = []
	for i in range(n):
		sm += arr[i]
		if sm != 0:
			print('YES')
			print(2)
			print(1, i + 1)
			print(i + 2, n)
			exit()
	else:
		print('NO')


n = int(input())
s = list(map(int, input().split()))
acc = [0 for i in range(110)]
ans = 0
for i in range(n):
	acc[i + 1] = ans + s[i]
	ans += s[i]
flag = 0
if ans != 0:
	flag = 1
	print('YES')
	print('1')
	print('%d %d' % (1, n))
else:
	for i in range(n - 1):
		if acc[i + 1] - acc[0] != 0 and acc[n] - acc[i + 1] != 0:
			print('YES')
			print('2')
			print('%d %d' % (1, i + 1))
			print('%d %d' % (i + 2, n))
			flag = 1
			break
if flag == 0:
	print('NO')


n = int(input())
ip = list(map(int, input().split()))
if sum(ip) != 0:
	print('YES')
	print(1)
	print(1, n)
else:
	ans = []
	count = 0
	for i in range(n):
		if ip[i] != 0:
			ans.append(ip[i])
			count += 1
			break
		else:
			ans.append(ip[i])
			count += 1
	if len(ans) == n:
		print('NO')
	else:
		print('YES')
		print(2)
		print(1, count)
		print(count + 1, n)


n = int(input())
a = list(map(int, input().split()))
if n == 1 and a[0] == 0:
	print('NO')
elif 0 not in a:
	print('YES')
	print(n)
	for i in range(1, n + 1):
		print(i, i, sep=' ')
else:
	i = 0
	c = 0
	j = 0
	m = []
	while i <= n - 1:
		c += a[i]
		if c != 0 and i == n - 1:
			m.append((j + 1, i + 1))
			i += 1
			j = i
			c = 0
		elif c != 0 and a[i + 1] != 0:
			m.append((j + 1, i + 1))
			i += 1
			j = i
			c = 0
		elif c != 0 and a[i + 1] == 0 and (i + 1 != n - 1):
			i += 1
		elif c != 0 and a[i + 1] == 0 and (i + 1 == n - 1):
			m.append((j + 1, i + 2))
			i += 1
			j = 1
			c = 0
		else:
			i += 1
	if len(m) == 0:
		print('NO')
	else:
		print('YES')
		print(len(m))
		for elem in m:
			print(*elem)


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


n = int(input())
a = [int(b) for b in input().split()]
ans = 0
indexes = []
if len(set(a)) == 1 and a[0] == 0:
	print('NO')
	exit()
if sum(a) != 0:
	print('YES')
	print(1)
	print(1, n)
	exit()
for i in range(n):
	if a[i] != 0:
		indexes.append(i)
print('YES')
print(2)
print(1, indexes[0] + 1)
print(indexes[0] + 2, n)


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