n = int(input())
arr = list(map(int, input().split()))
res = []
occ = [-1] * n
maxLen = -1
i = 0
arr.append(arr[-1]) # Sentinel
n += 1
for j in range(n):
x = arr[j]
if occ[x] >= i:
curLen = j - i
if curLen > maxLen:
maxLen = curLen
res = [(i+1, j)]
elif curLen == maxLen:
res.append((i+1, j))
i = occ[x] + 1 # Jump
occ[x] = j
print(len(res))
print('\n'.join(f"{t[0]} {t[1]}" for t in sorted(res)))



京公网安备 11010502036488号