One day Jeff got hold of an integer sequence a_1, a_2, ..., a_{n} of length n. The boy immediately decided to analyze the sequence. For that, he needs to find all values of x, for which these conditions hold:

  x occurs in sequence a.  Consider all positions of numbers x in the sequence a (such i, that a_{i} = x). These numbers, sorted in the increasing order, must form an arithmetic progression. 

Help Jeff, find all x that meet the problem conditions.


-----Input-----

The first line contains integer n (1 ≤ n ≤ 10^5). The next line contains integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^5). The numbers are separated by spaces.


-----Output-----

In the first line print integer t — the number of valid x. On each of the next t lines print two integers x and p_{x}, where x is current suitable value, p_{x} is the common difference between numbers in the progression (if x occurs exactly once in the sequence, p_{x} must equal 0). Print the pairs in the order of increasing x.


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

Output
1
2 0

Input
8
1 2 1 3 1 2 1 5

Output
4
1 2
2 4
3 0
5 0



-----Note-----

In the first test 2 occurs exactly once in the sequence, ergo p_2 = 0.

Difficulty: EASY

Solutions:
n = int(input())
L = list(map(int, input().split()))
dic = {}
for i in range(n):
	if L[i] not in dic:
		dic[L[i]] = [i, 0]
	elif dic[L[i]][1] == 0:
		dic[L[i]][1] = i - dic[L[i]][0]
		dic[L[i]][0] = i
	elif dic[L[i]][1] != -1:
		if i - dic[L[i]][0] == dic[L[i]][1]:
			dic[L[i]][0] = i
		else:
			dic[L[i]][1] = -1
count = 0
for each in dic:
	if dic[each][1] != -1:
		count += 1
print(count)
for each in sorted(dic):
	if dic[each][1] != -1:
		print(each, dic[each][1])


def arr_inp():
	return [int(x) for x in input().split()]

def diff(x, y):
	arr.append(y - x)
	return y
from collections import *
from functools import *
(n, a, mem, out) = (int(input()), arr_inp(), defaultdict(list), [])
for i in range(n):
	if mem[a[i]] != -1:
		if mem[a[i]] == []:
			mem[a[i]].extend([i, 0])
		elif mem[a[i]][1] == 0:
			mem[a[i]][1] = i - mem[a[i]][0]
			mem[a[i]][0] = i
		elif i - mem[a[i]][0] == mem[a[i]][1]:
			mem[a[i]][0] = i
		else:
			mem[a[i]] = -1
for (i, j) in mem.items():
	if j != -1:
		out.append([i, j[1]])
print(len(out))
for (i, j) in sorted(out):
	print(i, j)


raselBhai = lambda : list(map(int, input().split()))
n = int(input())
lst = raselBhai()
m = 10 ** 5 + 5
dst = [-1] * m
pst = [-1] * m
for i in range(n):
	if pst[lst[i]] == -1:
		dst[lst[i]] = 0
	elif i - pst[lst[i]] != dst[lst[i]]:
		if dst[lst[i]] == 0:
			dst[lst[i]] = i - pst[lst[i]]
		else:
			dst[lst[i]] = -1
	pst[lst[i]] = i
cnt = 0
for i in range(m):
	if dst[i] != -1:
		cnt += 1
print(cnt)
print('\n'.join(('{0} {1}'.format(i, dst[i]) for i in range(m) if dst[i] != -1)))


n = int(input())
a = tuple(map(int, input().split()))
u = {}
v = {}
w = []
for (i, x) in enumerate(a):
	if x in v:
		v[x].append(i)
	else:
		v[x] = [i]
for (x, li) in v.items():
	if len(li) == 1:
		w.append((x, 0))
	else:
		s = set([li[i] - li[i - 1] for i in range(1, len(li))])
		if len(s) == 1:
			w.append((x, s.pop()))
print(len(w))
print('\n'.join(('%d %d' % x for x in sorted(w))))


from sys import stdin

def isAP(arr):
	n = len(arr)
	if n == 1:
		return 0
	if n == 2:
		return arr[1] - arr[0]
	flag = 0
	diff = arr[1] - arr[0]
	for i in range(2, len(arr)):
		temp = arr[i] - arr[i - 1]
		if temp != diff:
			return -999999
	return diff
n = int(stdin.readline())
a = [int(i) for i in stdin.readline().split(' ')]
s = set(a)
dic = {}
for (i, val) in enumerate(a):
	if val not in dic:
		dic[val] = [i + 1]
	else:
		temp = dic[val]
		temp.append(i + 1)
		dic[val] = temp
l = []
for (key, value) in dic.items():
	temp = isAP(value)
	if temp == -999999:
		continue
	else:
		l.append([key, temp])
print(len(l))
l = sorted(l, key=lambda x: x[0])
for i in l:
	print(i[0], i[1])


n = int(input())
nums = list(map(int, input().split()))
lastX = {}
period = {}
good = {}
for i in range(n):
	if nums[i] not in lastX:
		lastX[nums[i]] = 0
		period[nums[i]] = 0
		good[nums[i]] = True
	elif period[nums[i]] == 0:
		period[nums[i]] = i - lastX[nums[i]]
	elif period[nums[i]] != i - lastX[nums[i]]:
		good[nums[i]] = False
	lastX[nums[i]] = i
score = 0
for key in good:
	if good[key] == True:
		score += 1
print(score)
keyList = sorted(list((key for key in lastX)))
for key in keyList:
	if good[key] == True:
		print(key, period[key])


n = int(input())
a = list(map(int, input().split()))
N = 100001
d = [-1] * N
p = [-1] * N
for i in range(n):
	if p[a[i]] == -1:
		d[a[i]] = 0
	elif i - p[a[i]] != d[a[i]]:
		if d[a[i]] == 0:
			d[a[i]] = i - p[a[i]]
		else:
			d[a[i]] = -1
	p[a[i]] = i
count = 0
for i in range(N):
	if d[i] != -1:
		count += 1
print(count)
print('\n'.join(('{0} {1}'.format(i, d[i]) for i in range(N) if d[i] != -1)))


n = int(input())
(inp, k) = ({}, 0)
s = input().split()
for i in range(0, len(s)):
	item = int(s[i])
	if item in inp:
		inp[item] += [i]
	else:
		inp[item] = [i]
inp_keys = [int(i) for i in inp.keys()]
inp_keys.sort()
result = []

def check(arr):
	diff = arr[1] - arr[0]
	for i in range(1, len(arr) - 1):
		if arr[i + 1] - arr[i] != diff:
			return False
	return diff
for i in inp_keys:
	j = inp[i]
	if len(j) == 1:
		result.append([i, 0])
		continue
	diff = check(j)
	if diff:
		result.append([i, diff])
out = ''
for (i, j) in result:
	out += str(i) + ' ' + str(j) + '\n'
print(len(result))
print(out[:-1])


import math
import random

def main(arr):
	pos = {}
	for i in range(len(arr)):
		if arr[i] not in pos:
			pos[arr[i]] = []
		pos[arr[i]].append(i)
	ans = []
	for e in pos:
		if len(pos[e]) == 1:
			ans.append([e, 0])
		else:
			dist = pos[e][1] - pos[e][0]
			v = True
			for i in range(0, len(pos[e]) - 1):
				if pos[e][i + 1] - pos[e][i] != dist:
					v = False
			if v:
				ans.append([e, dist])
	ans.sort(key=lambda x: x[0])
	print(len(ans))
	for e in ans:
		print(*e)
n = int(input())
arr = list(map(int, input().split()))
main(arr)


from collections import defaultdict

def fun(i):
	arr = []
	for j in range(1, len(i)):
		arr.append(i[j] - i[j - 1])
	if len(set(arr)) == 1:
		return arr[0]
	return 0

def solve(n, arr):
	(ans, valid) = ([], 0)
	art = defaultdict(list)
	for s in range(n):
		art[arr[s]].append(s)
	for (i, v) in art.items():
		if len(art[i]) == 1:
			ans.append((i, 0))
			valid += 1
		else:
			t = fun(art[i])
			if t != 0:
				ans.append((i, t))
				valid += 1
	return (sorted(ans), valid)
n = int(input())
arr = list(map(int, input().split()))
(ans, valid) = solve(n, arr)
print(valid)
if valid:
	for i in ans:
		print(i[0], i[1])


import sys, os, io, time, copy
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
import math

def main():
	n = int(input())
	arr = list(map(int, input().split()))
	dic = {}
	for i in range(n):
		if arr[i] not in dic:
			dic[arr[i]] = [i]
		else:
			dic[arr[i]].append(i)
	count = 0
	res = []
	for k in sorted(dic.keys()):
		a = dic[k]
		if len(a) == 1:
			count += 1
			res.append((k, 0))
		else:
			diff = a[1] - a[0]
			flag = 0
			for i in range(1, len(a)):
				d = a[i] - a[i - 1]
				if d != diff:
					flag = 1
					break
			if flag == 0:
				count += 1
				res.append((k, diff))
	print(count)
	for (x, p) in res:
		print(x, p)
main()


import math
n = int(input())
nums = list(map(int, input().split()))
s = sorted(set(nums))
d = {}
ans = []
for i in range(len(s)):
	d[s[i]] = []
for i in range(n):
	d[nums[i]].append(i)
vals = list(d.values())
keys = list(d.keys())
for i in range(len(vals)):
	if len(vals[i]) == 1:
		ans.append(str(keys[i]) + ' 0')
	else:
		dif = vals[i][1] - vals[i][0]
		ok = True
		for v in range(len(vals[i]) - 1):
			if vals[i][v + 1] - vals[i][v] != dif:
				ok = False
				break
		if ok:
			ans.append(str(keys[i]) + ' ' + str(dif))
print(len(ans))
for i in range(len(ans)):
	print(ans[i])


n = int(input())
A = list(map(int, input().split()))
from collections import defaultdict
dict = defaultdict(list)
for i in range(n):
	dict[A[i]].append(i)
ans = []
for a in sorted(dict.keys()):
	if len(dict[a]) == 1:
		ans.append([a, 0])
	else:
		A = sorted(dict[a])
		p = A[1] - A[0]
		for i in range(2, len(A)):
			if A[i] - A[i - 1] != p:
				break
		else:
			ans.append([a, p])
print(len(ans))
for a in ans:
	print(*a)


n = int(input())
a = list(map(int, input().split()))
v = dict()
for i in range(n):
	x = a[i]
	if x in v:
		v[x] = [i, -1 if v[x][1] and i - v[x][0] != v[x][1] else i - v[x][0]]
	else:
		v[x] = (i, 0)
b = [(x, v[x][1]) for x in sorted(v.keys()) if v[x][1] >= 0]
print(len(b))
for (x, p) in b:
	print(x, p)


n = int(input())
arr = list(map(int, input().split()))
brr = []
for i in range(max(arr) + 1):
	brr.append([])
for i in range(n):
	brr[arr[i] - 1].append(i + 1)
ans = []
for x in brr:
	if len(x) != 0:
		if len(x) == 1 or len(x) == 2:
			ans.append(x)
		else:
			z = []
			for j in range(1, len(x)):
				z.append(x[j] - x[j - 1])
			if len(set(z)) == 1:
				ans.append(x)
			else:
				ans.append([0])
	else:
		ans.append([0])
bns = list(filter(lambda y: y[0] != 0, ans))
print(len(bns))
for i in range(len(ans)):
	if ans[i][0] != 0:
		if len(ans[i]) == 1:
			print(i + 1, '0')
		else:
			print(i + 1, ans[i][1] - ans[i][0])


n = int(input())
A = list(map(int, input().split()))
B = [0] * (10 ** 5 + 1)
D = [0] * (10 ** 5 + 1)
M = set(A)
C = []
for i in range(n):
	if B[A[i]] == 0:
		B[A[i]] = i + 1
	elif B[A[i]] != -1:
		e = B[A[i]]
		if D[A[i]] == 0:
			D[A[i]] = i + 1 - e
			B[A[i]] = i + 1
		elif D[A[i]] == i + 1 - e:
			B[A[i]] = i + 1
		else:
			B[A[i]] = D[A[i]] = -1
			C.append(A[i])
print(len(M) - len(C))
M = list(M)
M.sort()
for i in M:
	if B[i] != -1:
		print(i, D[i])


n = int(input())
l = list(map(int, input().split()))
res = {}
res1 = {}

def isarp(l):
	dif = l[1] - l[0]
	for (i1, i2) in zip(l[:-1], l[1:]):
		if i2 - i1 != dif:
			return (False, None)
	return (True, dif)
for (i, v) in enumerate(l):
	if v in res:
		res[v].append(i)
	else:
		res[v] = [i]
for (k, v) in res.items():
	if len(v) > 1:
		(isp, dif) = isarp(v)
		if isp:
			res1[k] = dif
	else:
		res1[k] = 0
res1 = [f'{k} {v}' for (k, v) in sorted(res1.items(), key=lambda x: x[0])]
print(len(res1))
print('\n'.join(res1))


from collections import defaultdict

def validate(sequence):
	a = sequence[0]
	d = sequence[1] - a
	for i in range(2, len(sequence)):
		if sequence[i] != a + i * d:
			return (None, None)
	return (a, d)
n = int(input())
array = list(map(int, input().split()))
HashTable = defaultdict(list)
for (idx, val) in enumerate(array):
	HashTable[val].append(idx + 1)
ans = []
for i in HashTable.keys():
	if len(HashTable[i]) == 1:
		ans.append([i, 0])
		continue
	(a, d) = validate(HashTable[i])
	if a != None:
		ans.append([i, d])
ans.sort()
print(len(ans))
for i in ans:
	print(i[0], i[1])


n = int(input())
a = list(map(int, input().split()))
s = [-1 for i in range(10 ** 5 + 1)]
d = [0 for i in range(10 ** 5 + 1)]
p = [True for i in range(10 ** 5 + 1)]
for i in range(n):
	if s[a[i]] != -1:
		x = i - s[a[i]]
		if d[a[i]] == 0:
			d[a[i]] = x
		elif d[a[i]] != x:
			p[a[i]] = False
	s[a[i]] = i
t = 0
for i in range(10 ** 5 + 1):
	if p[i] == True and s[i] != -1:
		t += 1
print(t)
for i in range(10 ** 5 + 1):
	if s[i] == -1 or p[i] == False:
		continue
	print(i, d[i])


n = int(input())
list1 = list(map(int, input().split()))
dict1 = {}
ll = [[] for i in range(100001)]
for i in range(n):
	if list1[i] in dict1:
		if dict1[list1[i]] == 0:
			dict1[list1[i]] = i + 1 - ll[list1[i]][0]
		elif dict1[list1[i]] > 0:
			xx = dict1[list1[i]]
			yy = i + 1 - ll[list1[i]][-1]
			if xx != yy:
				dict1[list1[i]] = -1
	else:
		dict1[list1[i]] = 0
	ll[list1[i]].append(i + 1)
c = 0
for i in range(1, 100001):
	if ll[i] and dict1[i] != -1:
		c += 1
print(c)
for i in range(1, 100001):
	if ll[i] and dict1[i] != -1:
		print(i, dict1[i])


import sys
n = int(sys.stdin.readline())
l = list(map(int, sys.stdin.readline().split()))
prev = [-1] * 100005
dist = [-1] * 100005
can = [1] * 100005
out = []
for i in range(0, n):
	if prev[l[i]] == -1:
		prev[l[i]] = i
		dist[l[i]] = 0
	elif dist[l[i]] == 0:
		dist[l[i]] = i - prev[l[i]]
		prev[l[i]] = i
	else:
		d = i - prev[l[i]]
		if d == dist[l[i]]:
			prev[l[i]] = i
		else:
			can[l[i]] = 0
for i in range(0, n):
	if can[l[i]] == 1:
		can[l[i]] = 0
		out.append(l[i])
out.sort()
print(len(out))
for i in range(0, len(out)):
	print(out[i], dist[out[i]])


import atexit
import io
import sys
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

def main():
	n = int(sys.stdin.readline())
	l = list(map(int, sys.stdin.readline().split()))
	oi = 0
	prev = [-1] * 100005
	dist = [-1] * 100005
	can = [1] * 100005
	out = [0] * 100005
	for i in range(n):
		if prev[l[i]] == -1:
			prev[l[i]] = i
			dist[l[i]] = 0
		elif dist[l[i]] == 0:
			dist[l[i]] = i - prev[l[i]]
			prev[l[i]] = i
		else:
			d = i - prev[l[i]]
			if d == dist[l[i]]:
				prev[l[i]] = i
			else:
				can[l[i]] = 0
	for i in range(n):
		if can[l[i]] == 1:
			can[l[i]] = 0
			out[oi] = l[i]
			oi += 1
	if oi > 0:
		out = out[:oi]
	out.sort()
	print(oi)
	for i in range(oi):
		print(out[i], dist[out[i]])
main()


def ap(lst):
	if len(lst) == 1:
		return (True, 0)
	diff = lst[1] - lst[0]
	for i in range(len(lst)):
		if lst[i] != lst[0] + diff * i:
			return (False, -1)
	return (True, diff)
n = int(input())
a = list(map(int, input().split()))
ans = dict()
for i in range(n):
	try:
		ans[a[i]].append(i)
	except:
		ans[a[i]] = [i]
res = []
for val in ans:
	(x, diff) = ap(ans[val])
	if x:
		res.append((val, diff))
res.sort()
print(len(res))
for x in res:
	print(x[0], x[1])


n = int(input())
arr = list(map(int, input().split()))
brr = list(enumerate(arr))
brr.sort(key=lambda x: x[1])
res = []
count = 0
i = 0
if n == 1:
	print('1')
	print(arr[0], 0)
else:
	while i < n:
		flag = True
		diff = 0
		while i + 1 < n and brr[i + 1][1] == brr[i][1]:
			if diff == 0:
				diff = brr[i + 1][0] - brr[i][0]
			elif diff != 0 and brr[i + 1][0] - brr[i][0] != diff:
				flag = False
			i += 1
		if flag:
			count += 1
			res.append([brr[i][1], diff])
		i += 1
	print(count)
	for i in range(len(res)):
		print(res[i][0], res[i][1])


from collections import *
n = int(input())
d = defaultdict(list)
A = map(int, input().split())
for (i, j) in enumerate(A):
	d[j].append(i)
solutions = []
for j in sorted(d):
	inds = d[j]
	if len(inds) == 1:
		solutions.append((j, 0))
	else:
		diff = inds[1] - inds[0]
		if all((inds[i + 1] - inds[i] == diff for i in range(len(inds) - 1))):
			solutions.append((j, diff))
print(len(solutions))
for (i, j) in solutions:
	print(i, j)


n = int(input())
a = list(map(int, input().split()))
d = dict()
for i in range(n):
	x = a[i]
	if a[i] in d:
		if d[x][1] and i - d[x][0] != d[x][1]:
			d[x] = [i, -1]
		else:
			d[x] = [i, i - d[x][0]]
	else:
		d[x] = [i, 0]
print(len([i for i in d if d[i][1] >= 0]))
for i in sorted(d.keys()):
	if d[i][1] >= 0:
		print(i, d[i][1])


n = int(input())
b = [(int(x), y) for (x, y) in zip(input().split(), list(range(n)))]
b.sort()
b += [(0, 0)]
t = 0
ans = []
i = 0
seq = 0
while i < n:
	while b[i][0] != b[i + 1][0]:
		ans.append(str(b[i][0]) + ' 0')
		i += 1
		if i == n:
			break
	if i == n:
		i += 1
	elif b[i][0] == b[i + 1][0]:
		seq = 0
		while b[i][0] == b[i + 1][0]:
			if seq == 0:
				seq = b[i + 1][1] - b[i][1]
				i += 1
			elif b[i + 1][1] - b[i][1] == seq:
				i += 1
			else:
				seq = -1
				i += 1
		if seq == -1:
			i += 1
		else:
			ans.append(str(b[i][0]) + ' ' + str(seq))
			i += 1
print(len(ans))
print('\n'.join(ans))


n = int(input())
l = [int(i) for i in input().split()]
d = {}
for i in range(n):
	if d.get(l[i], -1) == -1:
		d[l[i]] = [0, i]
	elif d[l[i]][0] == 0:
		d[l[i]] = [i - d[l[i]][1], i]
	elif i - d[l[i]][1] == d[l[i]][0]:
		d[l[i]] = [d[l[i]][0], i]
	else:
		d[l[i]] = [-n, -n]
ans = 0
for i in d.keys():
	if d[i][0] >= 0:
		ans += 1
print(ans)
for i in sorted(d.keys()):
	if d[i][0] >= 0:
		print(i, d[i][0])


n = int(input())
a = [int(i) for i in input().split()]
b = [-1] * 100001
c = [0] * 100001
for i in range(0, n):
	if b[a[i]] == -1:
		b[a[i]] = i
	elif c[a[i]] == 0:
		c[a[i]] = i - b[a[i]]
		b[a[i]] = i
	elif c[a[i]] != -1:
		m = i - b[a[i]]
		if c[a[i]] != m:
			c[a[i]] = -1
		b[a[i]] = i
a = list(set(a))
a.sort()
ans = []
for i in range(0, len(a)):
	if c[a[i]] != -1:
		ans.append([a[i], c[a[i]]])
print(len(ans))
for i in range(0, len(ans)):
	print(ans[i][0], ans[i][1])


import math

def solution():
	n = int(input())
	l = input().split()
	m = {}
	b = set()
	for i in range(n):
		c = int(l[i])
		if c not in b:
			if c not in m:
				m[c] = (i, 0)
			elif m[c][1] == 0:
				m[c] = (i, i - m[c][0])
			elif i - m[c][0] == m[c][1]:
				m[c] = (i, m[c][1])
			else:
				b.add(c)
				del m[c]
	print(len(m))
	for x in sorted(m.keys()):
		print(x, m[x][1])
solution()


from collections import defaultdict
n = input()
t = list(map(int, input().split()))
(p, d) = (defaultdict(int), defaultdict(int))
for (i, x) in enumerate(t, 1):
	if d[x] < 0:
		continue
	if p[x]:
		if d[x] and i != p[x] + d[x]:
			d[x] = -1
		else:
			d[x] = i - p[x]
	p[x] = i
y = list(d.keys())
y.sort()
t = list((str(x) + ' ' + str(d[x]) for x in y if d[x] >= 0))
print(len(t))
print('\n'.join(t))


N = int(input())
f = []
a = list(map(int, input().split()))
f = [(a[i], i) for i in range(N)]
f.sort(key=lambda tup: (tup[0], tup[1]))
g = []
cu = f[0][0]
c = 0
pos = 1
s = -1
string = ''
while pos < N:
	if f[pos][0] == cu and s == -1:
		s = f[pos][1] - f[pos - 1][1]
		pos += 1
	elif f[pos][0] == cu and s == f[pos][1] - f[pos - 1][1]:
		pos += 1
	elif f[pos][0] == cu and s != f[pos][1] - f[pos - 1][1]:
		s = -2
		pos += 1
	elif s == -1:
		string += str(cu) + ' ' + str(0) + '\n'
		cu = f[pos][0]
		c += 1
		pos += 1
	elif s == -2:
		cu = f[pos][0]
		pos += 1
		s = -1
	else:
		string += str(cu) + ' ' + str(s) + '\n'
		cu = f[pos][0]
		pos += 1
		s = -1
		c += 1
if s == -1:
	string += str(cu) + ' ' + str(0) + '\n'
	c += 1
elif s != -2:
	string += str(cu) + ' ' + str(s) + '\n'
	c += 1
print(c)
print(string)


n = int(input())
a = [(int(x), y) for (x, y) in zip(input().split(), range(n))]
a.sort()
i = j = 0
l = []
while i < n:
	while j < n and a[i][0] == a[j][0]:
		j += 1
	i += 1
	if i == j:
		l.append(str(a[i - 1][0]) + ' 0')
	else:
		k = a[i][1] - a[i - 1][1]
		while i < j and a[i][1] - a[i - 1][1] == k:
			i += 1
		if i == j:
			l.append(str(a[i - 1][0]) + ' ' + str(k))
	i = j
print(len(l))
print('\n'.join(l))


import sys
input = sys.stdin.readline
read_tuple = lambda _type: map(_type, input().split(' '))

def solve():
	n = int(input())
	a = read_tuple(int)
	seqs = {}
	for (i, a_i) in enumerate(a):
		if a_i in seqs:
			seqs[a_i].append(i)
		else:
			seqs[a_i] = [i]
	x = []
	for (k, v) in seqs.items():
		if len(v) == 1:
			x.append((k, 0))
		else:
			diffs = set()
			for i in range(1, len(v)):
				diffs.add(v[i] - v[i - 1])
			if len(diffs) == 1:
				x.append((k, diffs.pop()))
	x.sort(key=lambda x: x[0])
	print(len(x))
	for (x, p_x) in x:
		print(x, p_x)
solve()


n = int(input())
a = list(map(int, input().split()))
dic = {}
ans = []
for i in range(n):
	dic.setdefault(a[i], [])
	dic[a[i]].append(i)
for (key, val) in dic.items():
	if len(val) < 2:
		ans.append((key, 0))
	elif len(val) < 3:
		ans.append((key, val[1] - val[0]))
	else:
		f = 1
		diff = val[1] - val[0]
		for i in range(2, len(val)):
			if val[i] - val[i - 1] != diff:
				f = 0
				break
		if f:
			ans.append((key, diff))
ans.sort()
print(len(ans))
for item in ans:
	print(*item)


import sys
n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
from collections import defaultdict
d = defaultdict(list)
for i in range(len(a)):
	d[a[i]] += [i]
for v in d.values():
	v.sort()
ans = []
c = 0
for (k, v) in d.items():
	if len(v) > 1:
		c = v[1] - v[0]
		flag = 0
		for j in range(1, len(v) - 1):
			if v[j + 1] - v[j] != c:
				flag = 1
				break
		if flag == 0:
			ans.append([k, c])
	else:
		ans.append([k, 0])
print(len(ans))
ans.sort()
for (i, j) in ans:
	print(i, end=' ')
	print(j)


m = [[] for i in range(100009)]
ll = []
o = 0
n = int(input())
l = list(map(int, input().split()))
for (i, ii) in enumerate(l):
	m[ii].append(i)
for (i, ii) in enumerate(m):
	if ii == []:
		continue
	elif len(ii) == 1:
		o += 1
		ll.append(str(i) + ' 0')
	elif len(ii) == 2:
		o += 1
		ll.append(str(i) + ' ' + str(ii[1] - ii[0]))
	else:
		dif = ii[1] - ii[0]
		for x in range(len(ii) - 1):
			if ii[x + 1] - ii[x] != dif:
				break
		else:
			o += 1
			ll.append(str(i) + ' ' + str(ii[1] - ii[0]))
print(o)
for i in ll:
	print(i)


n = int(input())
a = [int(i) for i in input().split()]
occ = dict()
for i in range(0, len(a)):
	if a[i] not in list(occ.keys()):
		occ[a[i]] = []
	occ[a[i]].append(i)
t = 0
out = ''
for k in sorted(occ.keys()):
	ini = occ[k][0]
	diff = 0
	if len(occ[k]) > 1:
		diff = occ[k][1] - occ[k][0]
	valid = True
	for i in range(2, len(occ[k])):
		if occ[k][i] - occ[k][i - 1] != diff:
			if a[0] == 100000:
				print(str(occ[k][i - 1]) + ' ' + str(occ[k][i]))
				return
			valid = False
			break
	if valid:
		out += str(k) + ' ' + str(diff) + '\n'
		t += 1
print(str(t) + '\n' + out)


from collections import defaultdict

def main():
	n = int(input())
	a = list(map(int, input().split(' ')))
	m = defaultdict(list)
	for i in range(n):
		m[a[i]].append(i)
	ret = []
	for k in m:
		if len(m[k]) == 1:
			ret.append((k, 0))
		else:
			v = m[k]
			diff = None
			good = True
			for i in range(1, len(v)):
				d = v[i] - v[i - 1]
				if diff == None:
					diff = d
				elif diff != d:
					good = False
					break
			if i == len(v) - 1 and good:
				ret.append((k, diff))
	ret = sorted(ret, key=lambda x: x[0])
	print(len(ret))
	for r in ret:
		print(r[0], r[1])
main()


n = int(input())
l = list(map(int, input().split()))
d1 = {}
d2 = {}
for i in sorted(set(l)):
	d1[i] = -1
for i in range(n):
	if d1[l[i]] != -2:
		if d1[l[i]] == -1:
			d1[l[i]] = 0
			d2[l[i]] = i
		elif d1[l[i]] == 0:
			d1[l[i]] = i - d2[l[i]]
			d2[l[i]] = i
		elif d1[l[i]] != i - d2[l[i]]:
			d1[l[i]] = -2
		else:
			d2[l[i]] = i
count = 0
for i in d1.values():
	if i != -2:
		count += 1
print(count)
for i in sorted(d1.keys()):
	if d1[i] != -2:
		print(i, d1[i])


le = int(input())
integers = [int(i) for i in str(input()).split(' ')]
d = {}
for (index, ele) in enumerate(integers):
	if ele in d:
		d[ele].append(index)
	else:
		d[ele] = [index]
ans = []
for (key, items) in d.items():
	if len(items) == 1:
		ans.append((key, 0))
	else:
		shouldAdd = True
		prog = items[1] - items[0]
		for i in range(1, len(items), 1):
			if items[i] - items[i - 1] != prog:
				shouldAdd = False
				break
		if shouldAdd:
			ans.append((key, prog))
print(len(ans))
for line in sorted(ans):
	print(line[0], line[1])


from collections import defaultdict
import sys
n = int(input())
arr = list(map(int, input().split()))
d = defaultdict(list)
blocklist = []
for i in range(len(arr)):
	if len(d[arr[i]]) < 2:
		d[arr[i]].append(i)
	elif arr[i] not in blocklist:
		if d[arr[i]][0] - d[arr[i]][1] == d[arr[i]][-1] - i:
			d[arr[i]].append(i)
		else:
			blocklist.append(arr[i])
num = len(d) - len(blocklist)
print(num)
for i in sorted(d.keys()):
	if i not in blocklist:
		dif = 0
		if len(d[i]) < 2:
			print(i, 0)
		else:
			dif = d[i][1] - d[i][0]
			print(i, dif)


def solve(n, nums):
	nums = [(nums[i], i) for i in range(n)]
	nums.sort()
	sol = []
	currX = nums[0][0]
	lastDiff = 0
	for i in range(1, n):
		if nums[i][0] == nums[i - 1][0]:
			currDiff = nums[i][1] - nums[i - 1][1]
			if lastDiff != currDiff and lastDiff != 0:
				lastDiff = -1
			else:
				lastDiff = currDiff
		else:
			if lastDiff == 0:
				sol.append([str(currX), '0'])
			elif lastDiff != -1:
				sol.append([str(currX), str(lastDiff)])
			currX = nums[i][0]
			lastDiff = 0
	if lastDiff == 0:
		sol.append([str(currX), '0'])
	elif lastDiff != -1:
		sol.append([str(currX), str(lastDiff)])
	return sol
n = int(input())
nums = list(map(int, input().split()))
sol = solve(n, nums)
print(len(sol))
for line in sol:
	print(' '.join(line))


from collections import defaultdict
n = int(input())
a = [int(x) for x in input().split()]
d = defaultdict(list)
for i in range(n):
	d[a[i]] += [i]
count = 0
ans = {}
for k in d.keys():
	lend = len(d[k])
	if lend == 1:
		count += 1
		ans[k] = 0
	else:
		prev = d[k][0]
		cd = d[k][1] - d[k][0]
		for i in range(1, lend):
			if not cd == d[k][i] - d[k][i - 1]:
				break
		else:
			count += 1
			ans[k] = cd
print(count)
for k in sorted(ans.keys()):
	print(k, ans[k])


dic = {}
n = int(input())
l = list(map(int, input().strip().split()))
for i in range(len(l)):
	if l[i] not in dic.keys():
		dic[l[i]] = list()
	dic[l[i]].append(i)
ans = list()
for i in sorted(dic.keys()):
	a = list(dic[i])
	if len(a) == 1:
		ans.append([i, 0])
	else:
		Flag = True
		com_dif = a[1] - a[0]
		for j in range(0, len(a) - 1):
			if a[j + 1] - a[j] != com_dif:
				Flag = False
				break
		if Flag:
			ans.append([i, com_dif])
print(len(ans))
for i in range(0, len(ans)):
	print(ans[i][0], ans[i][1])


n = int(input())
A = list(map(int, input().split()))
d = {}
for (i, u) in enumerate(A):
	x = d.get(u, 0)
	if x == 0:
		d[u] = [i]
	elif x == -1:
		continue
	elif len(x) == 1:
		d[u] = [i - d[u][0], i]
	elif d[u][1] + d[u][0] == i:
		d[u] = [d[u][0], i]
	else:
		d[u] = -1
ans = []
for k in d:
	if d[k] == -1:
		continue
	if len(d[k]) == 1:
		ans.append([k, 0])
		continue
	ans.append([k, d[k][0]])
print(len(ans))
ans.sort()
for ele in ans:
	print(*ele)


n = int(input())
d = {}
c = 1
for i in map(int, input().split()):
	d.setdefault(i, []).append(c)
	c += 1
for i in sorted(d):
	if len(d[i]) > 2:
		k = d[i][1] - d[i][0]
		if not all((j - i == k for (i, j) in zip(d[i], d[i][1:]))):
			del d[i]
print(len(d))
for i in sorted(d):
	if len(d[i]) == 1:
		print(i, 0)
		continue
	print(i, d[i][1] - d[i][0])


get = lambda : list(map(int, input().split()))

def isap(l):
	if len(l) < 2:
		return len(l) - 1
	d = l[1] - l[0]
	i = 0
	n = len(l)
	while i < n - 1:
		if l[i + 1] - l[i] != d:
			return -1
		i += 1
	return d
o = 33
n = int(input())
l = get()
from collections import defaultdict
d = defaultdict(lambda : [])
for (j, i) in enumerate(l):
	d[i].append(j)
ans = {}
for x in d:
	t = isap(d[x])
	if t != -1:
		ans[x] = t
print(len(ans))
for i in sorted(ans):
	print(i, ans[i])


n = int(input())
a = list(map(int, input().split()))
u = {}
v = {}
w = []
for (i, x) in enumerate(a):
	if x in v:
		v[x].append(i)
	else:
		v[x] = [i]
for (x, li) in list(v.items()):
	if len(li) == 1:
		w.append((x, 0))
	else:
		d = li[1] - li[0]
		sign = True
		for i in range(1, len(li)):
			if li[i] - li[i - 1] != d:
				sign = False
		if sign:
			w.append((x, d))
print(len(w))
print('\n'.join(('%d %d' % x for x in sorted(w))))


n = int(input())
c = [int(x) for x in input().split(' ')]
e = {}
for i in range(n):
	if c[i] not in e.keys():
		e[c[i]] = [i, 0]
	elif e[c[i]][1] == 0:
		e[c[i]] = [i, i - e[c[i]][0]]
	elif i - e[c[i]][0] == e[c[i]][1]:
		e[c[i]] = [i, i - e[c[i]][0]]
	else:
		e[c[i]] = [i, -1]
d = []
for i in e.keys():
	if e[i][1] != -1:
		d.append((i, e[i][1]))
print(len(d))
d.sort(key=lambda x: x[0])
for (a, b) in d:
	print(a, b)


import io
import os

def main():
	n = int(input())
	a = list(map(int, input().split()))
	b = sorted([(val, index) for (index, val) in enumerate(a)])

	def isProg(l):
		if len(l) == 1:
			return (True, 0)
		elif len(l) == 2:
			return (True, l[1] - l[0])
		diff = l[1] - l[0]
		for i in range(2, len(l)):
			if l[i] - l[i - 1] != diff:
				return (False, -1)
		return (True, diff)
	res = 0
	res_prog = []
	start = 0
	while start < n:
		end = start
		c = [b[end][1]]
		while end + 1 < n and b[end + 1][0] == b[start][0]:
			end += 1
			c.append(b[end][1])
		(isOk, diff) = isProg(c)
		if isOk:
			res += 1
			res_prog.append([b[start][0], diff])
		start = end + 1
	print(res)
	for i in range(res):
		print(res_prog[i][0], res_prog[i][1])
main()


input()
a = list(map(int, input().split()))
d = {}
count = 0
for (i, v) in enumerate(a):
	if v not in d:
		d[v] = (0, i)
		count += 1
	elif d[v]:
		(progress, last_index) = d[v]
		if progress == 0:
			d[v] = (i - last_index, i)
		elif i - last_index != progress:
			d[v] = False
			count -= 1
		else:
			d[v] = (progress, i)
print(count)
for key in sorted(d.keys()):
	if d[key]:
		print(*[key, d[key][0]])


def main():
	input()
	aa = [0] * 200002
	for (i, x) in enumerate(map(int, input().split()), 1):
		x *= 2
		(j, step) = (aa[x], aa[x + 1])
		if j:
			if step:
				if j + step != i:
					aa[x + 1] = -1
			else:
				aa[x + 1] = i - j
		aa[x] = i
	res = []
	for x in range(2, len(aa), 2):
		(j, step) = (aa[x], aa[x + 1])
		if j and step != -1:
			res.append(' '.join((str(x // 2), str(step))))
	print(len(res))
	print('\n'.join(res))
main()


import sys
from functools import reduce
from collections import Counter
import time
import datetime
from math import sqrt, gcd

def ip():
	return int(sys.stdin.readline())

def sip():
	return sys.stdin.readline()

def mip():
	return map(int, sys.stdin.readline().split())

def mips():
	return map(str, sys.stdin.readline().split())

def lip():
	return list(map(int, sys.stdin.readline().split()))

def matip(n, m):
	lst = []
	for i in range(n):
		arr = lip()
		lst.append(arr)
	return lst

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def minJumps(arr, n):
	jumps = [0 for i in range(n)]
	if n == 0 or arr[0] == 0:
		return float('inf')
	jumps[0] = 0
	for i in range(1, n):
		jumps[i] = float('inf')
		for j in range(i):
			if i <= j + arr[j] and jumps[j] != float('inf'):
				jumps[i] = min(jumps[i], jumps[j] + 1)
				break
	return jumps[n - 1]

def dic(arr):
	return Counter(arr)

def check_prime(n):
	if n < 2:
		return False
	for i in range(2, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True
n = ip()
arr = lip()
dick = {}
b = set()
for i in range(n):
	c = int(arr[i])
	if c not in b:
		if c not in dick:
			dick[c] = (i, 0)
		elif dick[c][1] == 0:
			dick[c] = (i, i - dick[c][0])
		elif i - dick[c][0] == dick[c][1]:
			dick[c] = (i, dick[c][1])
		else:
			b.add(c)
			del dick[c]
print(len(dick))
for x in sorted(dick.keys()):
	print(x, dick[x][1])


def solution(arr, n):
	mxm = max(arr) + 1
	progressions = [[-1, -1, True] for i in range(mxm + 1)]
	cnt = 0
	cnts = [0] * (mxm + 1)
	for i in range(n):
		if cnts[arr[i]]:
			continue
		cnts[arr[i]] = 1
		cnt += 1
	if cnt == n:
		print(n)
		arr.sort()
		for i in arr:
			print(i, 0)
		return
	for i in range(n):
		if progressions[arr[i]][1] == -1:
			progressions[arr[i]][1] = i
			progressions[arr[i]][0] = 0
		elif progressions[arr[i]][0] == 0:
			progressions[arr[i]][0] = i - progressions[arr[i]][1]
			progressions[arr[i]][1] = i
		elif progressions[arr[i]][0] != i - progressions[arr[i]][1] and progressions[arr[i]][2]:
			progressions[arr[i]][2] = False
			cnt -= 1
		else:
			progressions[arr[i]][1] = i
	print(cnt)
	for i in range(1, mxm):
		if progressions[i][0] >= 0 and progressions[i][2]:
			print(i, progressions[i][0])
n = int(input())
arr = list(map(int, input().split()))
solution(arr, n)


def check(v):
	l = []
	for i in range(1, len(v)):
		l.append(v[i] - v[i - 1])
	return len(set(l)) == 1
n = int(input())
a = list(map(int, input().split()))
m = dict()
if n == 1:
	print(1)
	print(a[0], 0)
else:
	idx = 1
	for i in a:
		if i not in m:
			m[i] = m.get(i, []) + [idx]
		else:
			m[i].append(idx)
		idx += 1
	l = dict()
	for (k, v) in m.items():
		if len(v) == 1:
			l[k] = 0
			continue
		elif check(v):
			l[k] = (v[-1] - v[0]) // (len(v) - 1)
	print(len(l))
	for i in sorted(l.items()):
		print(*i)


n = int(input())
arr = list(map(int, input().split()))
(i, d) = (0, {})
for j in arr:
	if j in d:
		d[j].append(i)
	else:
		d[j] = [i]
	i += 1
res = []
for (x, v) in d.items():
	if len(v) == 1:
		res.append((x, 0))
	else:
		s = set([v[i] - v[i - 1] for i in range(1, len(v))])
		if len(s) == 1:
			res.append((x, s.pop()))
print(len(res))
s = ''
for (i, j) in sorted(res):
	s += str(i) + ' ' + str(j) + '\n'
print(s)


n = int(input())
l = list(map(int, input().split()))
m = []
ll = []
for i in range(len(l)):
	m.append((l[i], i))
m.sort()
k = 0
for i in range(n - 1):
	if i == n - 2:
		if m[i][0] == m[i + 1][0]:
			if k != -1:
				if k == 0:
					ll.append((m[i][0], abs(m[i][1] - m[i + 1][1])))
				elif k == abs(m[i][1] - m[i + 1][1]):
					ll.append((m[i][0], k))
		else:
			if k != -1:
				ll.append((m[i][0], k))
			ll.append((m[i + 1][0], 0))
	elif m[i][0] == m[i + 1][0]:
		if k == 0:
			k = abs(m[i][1] - m[i + 1][1])
		elif k != abs(m[i][1] - m[i + 1][1]):
			k = -1
	elif k == -1:
		k = 0
	else:
		ll.append((m[i][0], k))
		k = 0
if n == 1:
	print(1)
	print(l[0], 0)
else:
	print(len(ll))
	for i in range(len(ll)):
		print(ll[i][0], ll[i][1])


from collections import defaultdict
d = {}
n = int(input())
nums = input().split(' ')
totals = 0
all_items = set()
eliminated = set()
for i in range(n):
	num = int(nums[i])
	if d.get(num, None) is not None:
		cur = d.get(num)
		if cur['failed']:
			continue
		if cur['distance'] == 0:
			cur['distance'] = i - cur['last']
			cur['last'] = i
		elif i - cur['last'] != cur['distance']:
			cur['failed'] = True
			totals -= 1
			eliminated.add(num)
		else:
			cur['last'] = i
	else:
		d[num] = {'last': i, 'distance': 0, 'failed': False}
		all_items.add(num)
		totals += 1
good_items = sorted(all_items - eliminated)
result = [(item, d[item]['distance']) for item in good_items]
print(totals)
for (i, v) in enumerate(result):
	print(v[0], v[1])


from collections import defaultdict as df
n = int(input())
a = list(map(int, input().rstrip().split()))
d = df(list)
for i in range(n):
	d[a[i]].append(i)
d = dict(sorted(d.items()))
result = []
for i in d:
	if len(d[i]) == 1:
		result.append((i, 0))
	elif len(d[i]) == 2:
		result.append((i, d[i][1] - d[i][0]))
	else:
		diff = d[i][1] - d[i][0]
		gg = 0
		for j in range(2, len(d[i])):
			if d[i][j] - d[i][j - 1] == diff:
				pass
			else:
				gg = 1
				break
		if gg == 0:
			result.append((i, diff))
print(len(result))
for i in result:
	print(i[0], i[1])


n = int(input())
array = list(map(int, input().split()))
d = {}
for i in range(n):
	if array[i] in d:
		temp = d[array[i]]
		temp[0] = temp[0] + 1
		temp[1].append(i)
		d[array[i]] = temp
	else:
		temp = [1, [i]]
		d[array[i]] = temp
ans = []
for (x, y) in d.items():
	if y[0] == 1:
		ans.append([x, y[0] - 1])
	elif y[0] == 2:
		ans.append([x, y[1][1] - y[1][0]])
	else:
		temp = y[1]
		diff = temp[1] - temp[0]
		flag = 0
		for i in range(1, len(temp) - 1):
			if temp[i + 1] - temp[i] != diff:
				flag = 1
				break
		if flag == 0:
			ans.append([x, diff])
ans.sort()
print(len(ans))
for x in ans:
	print(x[0], x[1])


import sys
from collections import defaultdict

def mi(s):
	return map(int, s.strip().split())

def lmi(s):
	return list(mi(s))

def mf(f, s):
	return map(f, s)

def lmf(f, s):
	return list(mf(f, s))

def seq(lst):
	if len(lst) == 1:
		return 0
	d = lst[1] - lst[0]
	for (a, b) in zip(lst, lst[1:]):
		nd = b - a
		if nd != d:
			return -1
	return d

def main(arr):
	pos = defaultdict(list)
	for (e, a) in enumerate(arr):
		pos[a].append(e)
	ans = []
	for n in pos:
		d = seq(pos[n])
		if d != -1:
			ans.append((n, d))
	print(len(ans))
	ans.sort()
	for (a, b) in ans:
		print(a, b)
for (e, line) in enumerate(sys.stdin.readlines()):
	if e == 0:
		continue
	else:
		arr = lmi(line)
main(arr)


def check(l):
	c = 0
	for i in range(len(l) - 1):
		if l[i + 1] - l[i] == l[1] - l[0]:
			c += 1
	if c == len(l) - 1:
		return [True, len(l)]
	else:
		return [False, 0]
n = int(input())
a = list(map(int, input().split()))
a = sorted(list(enumerate(a)), key=lambda i: i[1])
res = []
d = dict()
for (f, s) in a:
	if s not in d:
		d[s] = []
		d[s].append(f)
	else:
		d[s].append(f)
tot = 0
for (k, v) in d.items():
	if check(v)[0]:
		tot += 1
if not tot:
	print(0)
else:
	print(tot)
	for (k, v) in d.items():
		if len(v) == 1:
			res.append([k, 0])
		elif check(v)[1] == len(v) and len(v) == 1:
			res.append([k, 0])
		elif check(v)[1] == len(v) and len(v) > 1:
			res.append([k, v[1] - v[0]])
	for i in range(tot):
		print(res[i][0], res[i][1])


n = int(input())
num = list(map(int, input().split()))
back = list(set(num))
back.sort()
na = [0] * (max(num) + 1)
ans = [0] * (max(num) + 1)
f = 0
for i in range(len(num)):
	if na[num[i]] > 0 and ans[num[i]] == 0:
		ans[num[i]] = i + 1 - na[num[i]]
		na[num[i]] = i + 1
	elif na[num[i]] > 0 and ans[num[i]] > 0:
		if ans[num[i]] == i + 1 - na[num[i]]:
			na[num[i]] = i + 1
			continue
		else:
			f += 1
			ans[num[i]] = -1
	elif na[num[i]] == 0:
		na[num[i]] = i + 1
if f == len(back):
	print(0)
else:
	print(len(back) - f)
	for i in back:
		if ans[i] != -1:
			print(i, ans[i])


def check_ap(lis):
	diff = lis[1] - lis[0]
	for i in range(2, len(lis)):
		if lis[i] - lis[i - 1] != diff:
			return False
	return True
n = int(input())
arr = list(map(int, input().split()))
dic = {}
for i in range(len(arr)):
	if arr[i] in dic:
		dic[arr[i]].append(i)
	else:
		dic[arr[i]] = [i]
se = set(dic)
lis = []
cnt = 0
for i in se:
	c = dic[i]
	if len(c) == 1:
		lis.append([i, 0])
		cnt += 1
	elif len(c) == 2:
		lis.append([i, c[1] - c[0]])
		cnt += 1
	elif check_ap(c):
		cnt += 1
		lis.append([i, c[1] - c[0]])
lis.sort()
print(cnt)
for i in lis:
	print(i[0], i[1])


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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')

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

def array():
	return [int(i) for i in input().split()]
n = int(input())
a = array()
last = {i: [-1, set()] for i in a}
for i in range(n):
	if last[a[i]][0] == -1:
		last[a[i]][0] = i
for i in range(n):
	if i != last[a[i]][0]:
		last[a[i]][1].add(i - last[a[i]][0])
		last[a[i]][0] = i
ans = []
for i in last:
	l = len(last[i][1])
	tot = list(last[i][1])
	if l == 0:
		ans.append((i, 0))
	elif l == 1:
		ans.append((i, tot[0]))
print(len(ans))
ans.sort()
for i in ans:
	print(*i)


n = int(input())
arr = [int(x) for x in input().split()]
d = {}
for i in range(n):
	if arr[i] not in d.keys():
		d[arr[i]] = []
	d[arr[i]].append(i)
ans = []
for k in sorted(list(d.keys())):
	a = d[k]
	if len(a) == 1:
		ans.append([k, 0])
	else:
		o = a[1] - a[0]
		f = 0
		for i in range(0, len(a) - 1):
			if a[i + 1] - a[i] != o:
				f = 1
				break
		if f == 0:
			ans.append([k, o])
print(len(ans))
for i in ans:
	print(*i)


n = int(input())
a = list(map(int, input().split()))
count = [[] for _ in range(max(a) + 1)]
for (i, v) in enumerate(a):
	count[v].append(i)
res = []
for (i, i_v) in enumerate(count):
	l = len(i_v)
	if l == 0:
		continue
	if l == 1:
		res.append([i, 0])
	elif l == 2:
		res.append([i, i_v[1] - i_v[0]])
	else:
		d = i_v[1] - i_v[0]
		f = True
		for j in range(1, l - 1):
			if i_v[j + 1] - i_v[j] != d:
				f = False
				break
		if f:
			res.append([i, d])
print(len(res))
for r in res:
	print(*r)


class Code:

	def __init__(self):
		self.n = int(input())
		self.arr = list(map(int, input().split()))

	def process(self):
		freq = dict()
		for (i, item) in enumerate(self.arr):
			if item not in freq:
				freq[item] = (i, 0)
			elif freq[item][1] != -1 and (freq[item][1] == 0 or i - freq[item][0] == freq[item][1]):
				freq[item] = (i, i - freq[item][0])
			else:
				freq[item] = (-1, -1)
		lis = []
		for item in sorted(freq):
			if freq[item][1] != -1:
				lis.append((item, freq[item][1]))
		print(len(lis))
		for item in lis:
			print(item[0], item[1])
code = Code()
code.process()


n = int(input())
a = list(map(int, input().split()))
m = []
for i in range(max(a) + 1):
	m.append([])
for i in range(n):
	m[a[i]].append(i)
x = []
d1 = []
for i in range(max(a) + 1):
	j = len(m[i])
	if j > 0:
		if j == 1:
			s = m[i][0]
			d = 0
		else:
			d = m[i][1] - m[i][0]
			s = j / 2 * (2 * m[i][0] + (j - 1) * d)
		if s == float(sum(m[i])):
			x.append(i)
			d1.append(d)
print(len(x))
for i in range(len(x)):
	print(x[i], d1[i])


def gint():
	return int(input())

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

def gfloat():
	return float(input())

def gfloat_arr():
	return list(map(float, input().split()))

def pair_int():
	return map(int, input().split())
INF = 1 << 31
dx = [-1, 0, 1, 0]
dy = [0, 1, 0, -1]
n = gint()
a = gint_arr()
res = []
ind = {}
for (i, x) in enumerate(a):
	if x in ind:
		ind[x].append(i)
	else:
		ind[x] = [i]
ind = sorted(ind.items())
for (k, v) in ind:
	diff = 0
	i = 1
	while i < len(v):
		if diff and v[i] - v[i - 1] != diff:
			diff = INF
			break
		diff = v[i] - v[i - 1]
		i += 1
	if diff != INF:
		res.append((k, diff))
print(len(res))
for (v, i) in res:
	print(v, i)


n = int(input())
a = input().split()
cdiff = [-1] * 100005
lastpos = [-1] * 100005
t = 0
for i in range(n):
	x = int(a[i])
	if cdiff[x] == -1 and lastpos[x] == -1:
		cdiff[x] = 0
	elif cdiff[x] > 0 and cdiff[x] != i - lastpos[x]:
		cdiff[x] = -2
	elif cdiff[x] == 0 and lastpos[x] > -1:
		cdiff[x] = i - lastpos[x]
	lastpos[x] = i
for i in range(100005):
	if cdiff[i] > -1:
		t += 1
print(t)
for i in range(100005):
	if cdiff[i] > -1:
		print(i, cdiff[i])


from collections import defaultdict

def solve(seq):
	d = defaultdict(list)
	for (key, e) in enumerate(seq):
		d[e].append(key)
	cnt = 0
	res = [-1] * 100001
	for (k, v) in d.items():
		if len(v) == 1:
			res[k] = 0
			cnt += 1
		else:
			diff = v[1] - v[0]
			for j in range(2, len(v)):
				if v[j] - v[j - 1] != diff:
					break
			else:
				res[k] = diff
				cnt += 1
	return (res, cnt)

def main():
	input()
	seq = [int(c) for c in input().split()]
	(ans, cnt) = solve(seq)
	print(cnt)
	for (i, e) in enumerate(ans):
		if e != -1:
			print(i, e)
main()


n = int(input())
myMap = {}

def check(k):
	if len(myMap[k]) == 1:
		return (k, 0)
	d = myMap[k][1] - myMap[k][0]
	for x in range(2, len(myMap[k])):
		if myMap[k][x] - myMap[k][x - 1] is not d:
			return None
	return (k, d)
for (i, item) in enumerate(input().split(' ')):
	if item in myMap:
		myMap[item].append(i)
	else:
		myMap[item] = [i]
ans = []
for k in myMap.keys():
	temp = check(k)
	if temp is not None:
		ans.append([int(temp[0]), int(temp[1])])
print(len(ans))
for item in sorted(ans):
	print(item[0], item[1])


import atexit
import io
import sys

def main():
	n = int(sys.stdin.readline())
	l = list(map(int, sys.stdin.readline().split()))
	oi = 0
	prev = [-1] * 100005
	dist = [-1] * 100005
	can = [1] * 100005
	out = [0] * 100005
	for i in range(n):
		if prev[l[i]] == -1:
			prev[l[i]] = i
			dist[l[i]] = 0
		elif dist[l[i]] == 0:
			dist[l[i]] = i - prev[l[i]]
			prev[l[i]] = i
		else:
			d = i - prev[l[i]]
			if d == dist[l[i]]:
				prev[l[i]] = i
			else:
				can[l[i]] = 0
	for i in range(n):
		if can[l[i]] == 1:
			can[l[i]] = 0
			out[oi] = l[i]
			oi += 1
	if oi > 0:
		out = out[:oi]
	out.sort()
	print(oi)
	for i in range(oi):
		print(out[i], dist[out[i]])
main()


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1000000000.0) + 7
n = iinput()
l = get_list()
d = {}
for (i, j) in enumerate(l):
	if j in d:
		d[j].append(i)
	else:
		d[j] = [i]
ans = []
for (k, v) in d.items():
	if len(v) == 1:
		ans.append((k, 0))
	else:
		diff = set([v[i] - v[i - 1] for i in range(1, len(v))])
		if len(diff) == 1:
			ans.append((k, diff.pop()))
ans.sort()
print(len(ans))
for item in ans:
	print(*item)


n = int(input())
arr = list(map(int, input().split()))
occ = dict()
for (idx, v) in enumerate(arr):
	if v in occ:
		occ[v].append(idx)
	else:
		occ[v] = [idx]
ans = list()
for x in occ:
	if len(occ[x]) == 1:
		ans.append((x, 0))
	else:
		serie = occ[x]
		diff = serie[1] - serie[0]
		valid = True
		for i in range(1, len(serie) - 1):
			if serie[i + 1] - serie[i] != diff:
				valid = False
				break
		if valid:
			ans.append((x, diff))
ans.sort()
print(len(ans))
for (a, b) in ans:
	print(a, b)


def calc(n, a):
	res = [None] * (10 ** 5 + 1)
	count = 0
	for (x_idx, x) in enumerate(a):
		if res[x] == None:
			res[x] = [x_idx, 0]
			count += 1
		elif res[x] == False:
			continue
		else:
			(start, step) = res[x]
			if step == 0:
				res[x] = [x_idx, x_idx - start]
			elif start + step != x_idx:
				res[x] = False
				count -= 1
			else:
				res[x] = [x_idx, step]
	print(count)
	for (x_idx, x) in enumerate(res):
		if x != None and x != False:
			print(str(x_idx) + ' ' + str(x[1]))
n = int(input())
a = list(map(int, input().split()))
calc(n, a)


n = int(input())
a = list(map(int, input().split()))
dic = dict()
for i in range(n):
	tmp = a[i]
	if tmp in dic:
		dic[tmp] = [i, -1 if dic[tmp][1] and i - dic[tmp][0] != dic[tmp][1] else i - dic[tmp][0]]
	else:
		dic[tmp] = (i, 0)
ans = []
for i in sorted(dic.keys()):
	if dic[i][1] >= 0:
		ans.append((i, dic[i][1]))
print(len(ans))
for (i, j) in ans:
	print(i, j)


n = int(input())
l = list(map(int, input().split()))
d = dict()
for i in range(len(l)):
	d.setdefault(l[i], []).append(i + 1)
for i in sorted(d):
	g = d[i]
	if len(g) > 1:
		k = g[1] - g[0]
		if not all((g[i + 1] - g[i] == k for i in range(len(g) - 1))):
			del d[i]
print(len(d))
for i in sorted(d):
	if len(d[i]) == 1:
		print(i, 0)
	else:
		print(i, d[i][1] - d[i][0])


n = int(input())
arr = [(int(i), y) for (i, y) in zip(input().split(), range(n))]
arr.sort()
arr.append((None, -1))
anch = arr[0][0]
count = 1
is_ar = True
c = 0
res = []
for i in range(1, n + 1):
	if arr[i][0] != anch:
		if is_ar:
			res.append((anch, c))
		is_ar = True
		count = 1
		anch = arr[i][0]
		c = 0
	else:
		count += 1
		if count == 2:
			c = arr[i][1] - arr[i - 1][1]
		elif arr[i][1] - arr[i - 1][1] != c:
			is_ar = False
print(len(res))
for e in res:
	print(*e)


def Periods(n, arr):
	memo = dict()
	peroid = [-2] * 100001
	count = 0
	for i in range(n):
		if peroid[arr[i]] != -1:
			if arr[i] not in memo.keys():
				memo[arr[i]] = i
				peroid[arr[i]] = 0
				count += 1
			elif arr[i] in memo.keys() and peroid[arr[i]] == 0:
				peroid[arr[i]] = i - memo[arr[i]]
				memo[arr[i]] = i
			elif arr[i] in memo.keys():
				if peroid[arr[i]] != i - memo[arr[i]]:
					peroid[arr[i]] = -1
					count -= 1
				else:
					memo[arr[i]] = i
	return (count, peroid)
n = int(input())
arr = list(map(int, input().split()))
a = Periods(n, arr)
print(a[0])
for i in range(len(a[1])):
	if a[1][i] >= 0:
		print(i, a[1][i])


3

def readln():
	return tuple(map(int, input().split()))
(n,) = readln()
var = {}
for (i, a) in enumerate(readln()):
	if a in var:
		var[a].append(i)
	else:
		var[a] = [i]
ans = []
for (x, v) in list(var.items()):
	if len(v) == 1:
		ans.append((x, 0))
	else:
		d = set([v[i] - v[i - 1] for i in range(1, len(v))])
		if len(d) == 1:
			ans.append((x, d.pop()))
print(len(ans))
print('\n'.join(('%d %d' % f for f in sorted(ans))))


num = int(input())
l = list(map(int, input().split()))
w = {}
for i in range(len(l)):
	if l[i] not in w:
		w[l[i]] = [i]
	else:
		w[l[i]] += [i]
s = []
for i in sorted(w):
	if len(w[i]) == 1:
		s.append(str(i) + ' ' + str(0))
	elif len(w[i]) == 2:
		s.append(str(i) + ' ' + str(abs(w[i][0] - w[i][1])))
	else:
		commondiff = abs(w[i][0] - w[i][1])
		for k in range(len(w[i]) - 1):
			if abs(w[i][k + 1] - w[i][k]) == commondiff:
				pass
			else:
				break
		else:
			s.append(str(i) + ' ' + str(commondiff))
print(len(s))
for i in s:
	print(i)


import sys
n = int(sys.stdin.readline())
ais = list(map(int, sys.stdin.readline().split()))
d = {}
for i in range(n):
	a = ais[i]
	if a not in d:
		d[a] = (i, 0)
	else:
		d[a] = (i, -1 if d[a][1] and i - d[a][0] != d[a][1] else i - d[a][0])
b = [(i, d[i][1]) for i in sorted(d.keys()) if d[i][1] >= 0]
print(len(b))
for i in b:
	print(i[0], i[1])


N = int(input())
seq = list(map(int, input().strip().split()))
index_dict = dict()
for (i, x) in enumerate(seq):
	if x in index_dict:
		index_dict[x].append(i)
	else:
		index_dict[x] = [i]
for key in index_dict:
	index_dict[key] = sorted(index_dict[key])
rslt = []
for key in index_dict:
	if len(index_dict[key]) == 1:
		rslt.append((key, 0))
	else:
		diff = index_dict[key][1] - index_dict[key][0]
		is_ap = True
		i = 2
		while i < len(index_dict[key]):
			if index_dict[key][i] - index_dict[key][i - 1] != diff:
				is_ap = False
				break
			i += 1
		if is_ap:
			rslt.append((key, diff))
rslt = sorted(rslt, key=lambda x: x[0])
print(len(rslt))
for x in rslt:
	print(x[0], x[1])


n = int(input())
l = [int(x) for x in input().split()]
d = {}
for i in range(len(l)):
	if l[i] not in d:
		d[l[i]] = [i]
	else:
		d[l[i]].append(i)
sol = []
for x in d:
	if len(d[x]) >= 2:
		diff = d[x][1] - d[x][0]
		found = False
		for y in range(1, len(d[x])):
			if d[x][y] - d[x][y - 1] != diff:
				found = True
				break
		if not found:
			sol.append([x, diff])
	else:
		sol.append([x, 0])
sol.sort()
print(len(sol))
for x in sol:
	print(x[0], x[1])


n = int(input())
l = list(map(int, input().split()))
dic = {}
for i in range(n):
	if l[i] not in dic.keys():
		dic[l[i]] = []
	dic[l[i]].append(i)
ans = []
for i in sorted(list(dic.keys())):
	a = dic[i]
	if len(a) == 1:
		ans.append([i, 0])
	else:
		o = a[1] - a[0]
		f = 0
		for k in range(0, len(a) - 1):
			if a[k + 1] - a[k] != o:
				f = 1
				break
		if f == 0:
			ans.append([i, o])
print(len(ans))
for i in ans:
	print(*i)


import sys

def get_ints():
	return list(map(int, sys.stdin.readline().strip().split()))
n = int(input())
arr = get_ints()
dicts = {}
for (i, j) in enumerate(arr):
	if j not in dicts:
		dicts[j] = []
	dicts[j].append(i)
ans = []
for (key, value) in dicts.items():
	if len(value) == 1:
		ans.append([key, 0])
	else:
		nn = len(value)
		samediff = value[1] - value[0]
		flag = 0
		for i in range(1, nn):
			if value[i] - value[i - 1] != samediff:
				flag = 1
				break
		if flag == 0:
			ans.append([key, value[1] - value[0]])
ans = sorted(ans)
getans = []
print(len(ans))
for tup in ans:
	firstelem = tup[0]
	secelem = tup[1]
	print(str(firstelem) + ' ' + str(secelem))


n = int(input())
a = list(map(int, input().split()))
d = {}
for i in range(n):
	if a[i] in d:
		if d[a[i]][1] == 0:
			d[a[i]] = [i, i - d[a[i]][0]]
		elif d[a[i]][1] != 'Null':
			if d[a[i]][1] == i - d[a[i]][0]:
				d[a[i]][0] = i
			else:
				d[a[i]][1] = 'Null'
	else:
		d[a[i]] = [i, 0]
ans = []
for (i, j) in d.items():
	if j[1] != 'Null':
		ans.append(str(i) + ' ' + str(j[1]))
ans.sort(key=lambda x: int(x.split()[0]))
print(len(ans))
print(*ans, sep='\n')


from sys import stdin, stdout
input = lambda : stdin.readline()
n = int(input())
arr = list(map(int, input().split()))
keys = set(arr)
dic = {i: [] for i in keys}
for i in range(n):
	dic[arr[i]].append(i)
count = 0
ans = []
for i in keys:
	if dic[i] == []:
		continue
	if len(dic[i]) == 1:
		count += 1
		ans.append((i, 0))
	else:
		req = dic[i][1] - dic[i][0]
		for j in range(len(dic[i]) - 1):
			if dic[i][j + 1] - dic[i][j] != req:
				break
		else:
			count += 1
			ans.append((i, req))
ans.sort()
print(count)
for (x, i) in ans:
	print(x, i)


from collections import defaultdict
n = int(input())
A = [int(a) for a in input().split()]
d = defaultdict(list)
for i in range(n):
	d[A[i]].append(i)
x = set(A)
valid = len(x)
to_print = []
for a in x:
	places = d[a]
	l = len(places)
	if l == 1:
		to_print.append((a, 0))
	else:
		dif = places[1] - places[0]
		valid_flag = True
		for j in range(2, l):
			if places[j] - places[j - 1] != dif:
				valid -= 1
				valid_flag = False
				break
		if valid_flag:
			to_print.append((a, dif))
print(valid)
to_print.sort(key=lambda l: l[0])
for (x, dif) in to_print:
	print(x, dif)


x = int(input())
l = list(map(int, input().split()))
d = {}
for i in range(x):
	m = l[i]
	if m in d:
		d[m] = (i, -1 if d[m][1] and i - d[m][0] != d[m][1] else i - d[m][0])
	else:
		d[m] = (i, 0)
b = [(p, d[p][1]) for p in sorted(d.keys()) if d[p][1] >= 0]
print(len(b))
for i in b:
	print(i[0], i[1])


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
from bisect import bisect_right
from collections import deque

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())
P = 1000000007

def main():
	n = I()
	arr = L()
	dict1 = {}
	c = 0
	for i in range(n):
		if arr[i] in dict1.keys():
			if dict1[arr[i]][0] == -1:
				continue
			elif dict1[arr[i]][0] == 0:
				dict1[arr[i]][0] = i - dict1[arr[i]][1]
				dict1[arr[i]][1] = i
			elif i - dict1[arr[i]][1] == dict1[arr[i]][0]:
				dict1[arr[i]][1] = i
			else:
				dict1[arr[i]][0] = -1
				c += 1
		else:
			dict1[arr[i]] = [0, i]
	print(len(dict1) - c)
	for key in sorted(dict1):
		if dict1[key][0] != -1:
			print(key, dict1[key][0])
main()


n = int(input())
a = list(map(int, input().split()))
x = 100001
p = [-1] * x
l = [-1] * x
t = 0
for i in range(n):
	if p[a[i]] == -1:
		p[a[i]] = 0
		l[a[i]] = i
	elif p[a[i]] == 0:
		p[a[i]] = i - l[a[i]]
		l[a[i]] = i
	elif p[a[i]] > 0:
		if p[a[i]] == i - l[a[i]]:
			l[a[i]] = i
		else:
			p[a[i]] = -2
s = ''
for i in range(x):
	if p[i] >= 0:
		t += 1
		s += str(i) + ' ' + str(p[i]) + '\n'
print(t)
print(s)


n = int(input())
seq = list(map(int, input().split()))
index_dict = {}
del_list = []
for (i, v) in enumerate(seq):
	if v not in index_dict:
		index_dict[v] = [i, 0]
	else:
		i_diff = i - index_dict[v][0]
		prev_diff = index_dict[v][1]
		if index_dict[v][0] != -1:
			index_dict[v][1] = i_diff
			index_dict[v][0] = i
		if prev_diff != 0:
			if i_diff != prev_diff:
				index_dict[v][0] = -1
				del_list.append(v)
index_dict = {k: v for (k, v) in sorted(index_dict.items(), key=lambda item: item[0])}
n = len(index_dict)
flag = 0
for (k, v) in index_dict.items():
	if v[0] == -1:
		flag += 1
if flag == n:
	print('0')
else:
	print(n - flag)
	for (k, v) in index_dict.items():
		if v[0] != -1:
			print('{} {}'.format(k, v[1]))


n = int(input())
arr = list(map(int, input().split()))
d = {}
for i in range(n):
	if arr[i] in d:
		val = d[arr[i]]
		val.append(i + 1)
		d[arr[i]] = val
	else:
		d[arr[i]] = [i + 1]
l = []
for i in d:
	newarr = []
	val = d[i]
	if len(val) == 1:
		newarr.append(i)
		newarr.append(0)
		l.append(newarr)
		continue
	diff = val[1] - val[0]
	leng = len(val)
	flag = 0
	for j in range(2, leng):
		newdiff = val[j] - val[j - 1]
		if newdiff != diff:
			flag = 1
			break
	if flag == 0:
		newarr.append(i)
		newarr.append(diff)
		l.append(newarr)
print(len(l))
l.sort(key=lambda x: x[0])
for i in l:
	print(str(i[0]) + ' ' + str(i[1]))


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

def find_diff(a):
	n = len(a)
	if n == 1:
		return 0
	diff = a[1] - a[0]
	for i in range(2, n):
		if a[i] - a[i - 1] != diff:
			return -1
	return diff
pos = {}
for i in range(len(a)):
	try:
		pos[a[i]].append(i)
	except:
		pos[a[i]] = [i]
ans = []
for i in pos:
	d = find_diff(pos[i])
	if d != -1:
		ans.append([i, d])
ans.sort()
print(len(ans))
for i in range(len(ans)):
	print(ans[i][0], ans[i][1])


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

def inAP(array, l, ele):
	if l == 1:
		return (True, ele, 0)
	d = array[0] - array[1]
	for i in range(1, l):
		if array[i - 1] - array[i] != d:
			return (False, -1, -1)
	return (True, ele, abs(d))
seen = {}
keys = []
for i in range(n):
	if arr[i] in seen:
		seen[arr[i]].append(i)
	else:
		seen[arr[i]] = [i]
		keys.append(arr[i])
keys.sort()
count = 0
s = []
for i in keys:
	l = len(seen[i])
	ans = inAP(seen[i], l, i)
	if ans[0]:
		count += 1
		s.extend([str(ans[1]), ' ', str(ans[2]), '\n'])
s = str(count) + '\n' + ''.join(s).strip()
print(s)


n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(100001):
	b.append([])
for i in range(n):
	b[a[i]].append(i + 1)
k = 0
for i in b:
	if 0 < len(i) <= 2:
		k += 1
	elif len(i) > 2:
		d = i[1] - i[0]
		poss = True
		for j in range(2, len(i)):
			if i[j] - i[j - 1] != d:
				poss = False
		if poss:
			k += 1
print(k)
for i in range(100001):
	if len(b[i]) == 1:
		print(i, 0)
	elif len(b[i]) == 2:
		print(i, b[i][1] - b[i][0])
	elif len(b[i]) > 2:
		d = b[i][1] - b[i][0]
		poss = True
		for j in range(2, len(b[i])):
			if b[i][j] - b[i][j - 1] != d:
				poss = False
		if poss:
			print(i, d)


n = int(input())
a = list(map(int, input().rstrip().split()))
li = []
for i in range(100001):
	li += [[0, -1, 0, 0]]
ans = []
for i in range(n):
	x = a[i]
	stat = li[x]
	if stat[1] == -1:
		li[x][1] = i
		li[x][3] = 1
		li[x][2] = 1
	elif stat[3] == 1:
		li[x][0] = i - stat[1]
		li[x][2] = 1
		li[x][3] = 2
		li[x][1] = i
	elif stat[2] == 1 and stat[0] == i - stat[1]:
		li[x][1] = i
		li[x][3] += 1
	elif stat[2] == 1 and stat[0] != i - stat[1]:
		li[x][2] = 0
		li[x][0] = -1
count = 0
for i in range(1, 100001):
	x = li[i]
	if x[2] == 1:
		count += 1
		ans += [i]
print(count)
for ind in ans:
	x = li[ind]
	if x[2] == 1:
		print(ind, x[0])


n = int(input())
Ar = [int(x) for x in input().split()]
Ar = [0] + Ar
A = {}
for i in range(1, n + 1):
	try:
		A[Ar[i]].append(i)
	except:
		A[Ar[i]] = [i]
cnt = 0
temp = []
for i in A:
	flag = 0
	if len(A[i]) > 1:
		diff = A[i][1] - A[i][0]
		for j in range(1, len(A[i])):
			if A[i][j] - A[i][j - 1] == diff:
				pass
			else:
				flag = 1
				break
		if flag == 0:
			cnt += 1
			temp.append([i, diff])
	else:
		temp.append([i, 0])
		cnt += 1
print(cnt)
temp.sort()
for i in temp:
	print(i[0], i[1])


n = int(input())
ls = list(map(int, input().split()))
memo = {}
for i in range(n):
	try:
		(last, diff, discarded) = memo[ls[i]]
		if not discarded:
			if diff == 0:
				memo[ls[i]][1] = i - memo[ls[i]][0]
				memo[ls[i]][0] = i
			elif i - last == diff:
				memo[ls[i]][0] = i
			elif i - last != diff:
				memo[ls[i]][2] = True
	except KeyError:
		memo[ls[i]] = [i, 0, False]
counter = 0
for value in memo.values():
	if not value[-1]:
		counter += 1
print(counter)
output = []
for (key, value) in memo.items():
	if not value[-1]:
		output.append((key, value[1]))
output.sort()
for ans in output:
	print(ans[0], ans[1])


def zip_sorted(a, b):
	(a, b) = zip(*sorted(zip(a, b)))
	sorted(zip(a, b), key=lambda x: x[1])
	return (a, b)
import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
S = lambda : list(map(str, input().split()))
(n,) = I()
g = [0] * (10 ** 5 + 2)
h = [0] * (10 ** 5 + 2)
j = [0] * (10 ** 5 + 2)
l = [0] * (10 ** 5 + 2)
a = I()
for i in range(len(a)):
	if g[a[i]] == 0:
		g[a[i]] = a[i]
		h[a[i]] = h[a[i]] + 1
		if h[a[i]] == 1:
			j[a[i]] = i
			l[a[i]] = i
		elif h[a[i]] == 2:
			j[a[i]] = i - l[a[i]]
			l[a[i]] = i
		elif j[a[i]] != i - l[a[i]]:
			h[a[i]] = -1 * (n + 1)
		else:
			l[a[i]] = i
			pass
	else:
		h[a[i]] = h[a[i]] + 1
		if h[a[i]] == 1:
			j[a[i]] = i
			l[a[i]] = i
		elif h[a[i]] == 2:
			j[a[i]] = i - l[a[i]]
			l[a[i]] = i
		elif j[a[i]] != i - l[a[i]]:
			h[a[i]] = -1 * (n + 1)
		else:
			l[a[i]] = i
			pass
count = 0
for i in range(len(g)):
	if g[i] > 0:
		if h[i] == 1:
			count = count + 1
		elif h[i] > 0:
			count = count + 1
print(count)
for i in range(len(g)):
	if g[i] > 0:
		if h[i] == 1:
			print(i, 0)
		elif h[i] > 0:
			print(i, j[i])


import collections, math, itertools, bisect, heapq, copy

class Solution:

	def solve(self):
		n = int(input())
		arr = list(map(int, input().rstrip().split()))
		d = {}
		for (i, num) in enumerate(arr):
			if num not in d:
				d[num] = [i]
			else:
				d[num].append(i)
		res = []
		for key in d:
			if len(d[key]) <= 2:
				res.append((key, d[key][-1] - d[key][0]))
			else:
				diff = d[key][1] - d[key][0]
				res.append((key, diff))
				for i in range(1, len(d[key])):
					if d[key][i] - d[key][i - 1] != diff:
						res.pop()
						break
		res = sorted(res)
		print(len(res))
		for item in res:
			print(item[0], item[1])
solution = Solution()
solution.solve()


import sys
import re
import math
MOD = 1000000007
inp = lambda : map(int, input().split(' '))
ninp = lambda : int(input())
n = ninp()
a = list(inp())
res = {}
for i in range(n):
	x = a[i]
	if x in res:
		res[x] = [i, -1 if res[x][1] and i - res[x][0] != res[x][1] else i - res[x][0]]
	else:
		res[x] = (i, 0)
ans = [(x, res[x][1]) for x in sorted(res.keys()) if res[x][1] >= 0]
print(len(ans))
for (x, y) in ans:
	print(x, y)


n = int(input())
a = list(map(int, input().split()))
dic = {}
for i in range(n):
	if a[i] not in dic:
		dic[a[i]] = [i + 1]
	else:
		dic[a[i]].append(i + 1)
ans = []
for key in dic:
	temp = dic[key]
	if len(temp) == 1:
		ans.append([key, 0])
	elif len(temp) == 2:
		ans.append([key, temp[1] - temp[0]])
	else:
		diff = temp[1] - temp[0]
		for i in range(1, len(temp)):
			if temp[i] - temp[i - 1] != diff:
				break
		else:
			ans.append([key, diff])
print(len(ans))
ans.sort()
for ans in ans:
	print(*ans, end='\n')


n = int(input())
a = [int(i) for i in input().split()]
k = max(a)
b = [[-1, -1, 1] for i in range(k + 1)]
for i in range(n):
	if b[a[i]][0] == -1:
		b[a[i]][0] = i
	elif b[a[i]][0] != -1:
		if b[a[i]][1] == -1:
			b[a[i]][1] = i - b[a[i]][0]
			b[a[i]][0] = i
		elif i - b[a[i]][0] == b[a[i]][1]:
			b[a[i]][0] = i
		else:
			b[a[i]][2] = 0
c = []
for i in range(1, k + 1):
	x = b[i]
	if x[2] == 1 and x[0] != -1:
		if x[1] == -1:
			c.append([i, 0])
		else:
			c.append([i, x[1]])
print(len(c))
for i in c:
	print('{} {}'.format(i[0], i[1]))


def AP(seq):
	d = seq[1] - seq[0]
	for i in range(1, len(seq) - 1):
		if seq[i + 1] - seq[i] != d:
			return -1
	return d

def main():
	n = int(input())
	s = input().split()
	data = {}
	answer = []
	for i in range(0, len(s)):
		item = s[i]
		if item in data:
			data[item] += [i]
		else:
			data[item] = [i]
	uniq = [int(item) for item in list(data.keys())]
	uniq.sort()
	for x in uniq:
		iters = data[str(x)]
		count = len(iters)
		if count == 1:
			answer.append([x, 0])
			continue
		d = AP(iters)
		if d != -1:
			answer.append([x, d])
	t = len(answer)
	print(t)
	s = ''
	for (a, b) in answer:
		s += str(a) + ' ' + str(b) + '\n'
	print(s[:-1])
main()


n = int(input())
l = list(map(int, input().split()))
arr = [0] * 100001
occ = [0] * 100001
dif = [0] * 100001
for i in range(n):
	val = l[i]
	if occ[val] == 0:
		arr[val] = i
	elif occ[val] == 1:
		dif[val] = i - arr[val]
		arr[val] = i
	elif occ[val] > 1:
		if dif[val] == i - arr[val]:
			arr[val] = i
		else:
			dif[val] = -1
	occ[val] += 1
results = []
for i in range(1, 100001):
	if occ[i] >= 1 and dif[i] != -1:
		results.append([i, dif[i]])
print(len(results))
for i in results:
	print(i[0], i[1])


n = int(input())
l = list(map(int, input().split()))
d = {}
for i in range(len(l)):
	if d.get(l[i], -1) == -1:
		d[l[i]] = [0, i]
	elif d[l[i]][0] == 0:
		d[l[i]] = [i - d[l[i]][1], i]
	elif i - d[l[i]][1] == d[l[i]][0]:
		d[l[i]] = [d[l[i]][0], i]
	else:
		d[l[i]] = [-n, -n]
k = 0
for i in d.keys():
	if d[i][0] >= 0:
		k += 1
print(k)
for i in sorted(d.keys()):
	if d[i][0] >= 0:
		print(i, d[i][0])


def is_ap(l):
	if len(l) == 1:
		return 0
	p = l[1] - l[0]
	for i in range(len(l) - 1):
		if l[i + 1] - l[i] != p:
			return None
	return p
n = int(input())
a = list(map(int, input().split()))
candidates = set(a)
indexes_dict = {candidate: [] for candidate in candidates}
for i in range(n):
	indexes_dict[a[i]].append(i)
answers = []
count = 0
for x in sorted(indexes_dict.keys()):
	p_x = is_ap(indexes_dict[x])
	if p_x is not None:
		count += 1
		answers.append(f'{x} {p_x}')
print(count)
for answer in answers:
	print(answer)


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
d = defaultdict(list)
ans = []
c = 0
for i in range(n):
	d[a[i]].append(i)
for i in d:
	l = d[i]
	if len(l) == 1:
		c += 1
		ans.append([i, 0])
	else:
		diff = l[1] - l[0]
		test = 0
		for j in range(1, len(d[i])):
			if l[j] - l[j - 1] != diff:
				test = 1
				break
		if not test:
			c += 1
			ans.append([i, diff])
print(c)
ans.sort()
for i in range(len(ans)):
	print(*ans[i])


import os
import sys
from io import BytesIO, IOBase
from types import GeneratorType
from bisect import *
from collections import defaultdict, deque, Counter
import math
import string
from heapq import *
from operator import add
from itertools import accumulate
BUFSIZE = 8192
sys.setrecursionlimit(10 ** 5)

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		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 = self.os.read(self._fd, max(self.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 = self.os.read(self._fd, max(self.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:
			self.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))

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

def en(x):
	return list(enumerate(x))

def ceil_(a, b):
	return (a + b - 1) // b

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

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

def rr():
	return list(r())

def go(arr):
	if len(arr) == 1:
		return 0
	d = arr[1] - arr[0]
	for i in range(len(arr) - 1):
		if arr[i + 1] - arr[i] != d:
			return -1
	return d
n = ii()
arr = rr()
brr = defaultdict(list)
for (i, j) in enumerate(arr):
	brr[j] += (i,)
ans = []
for i in brr.keys():
	d = go(brr[i])
	if d == -1:
		continue
	else:
		ans += ([i, d],)
ans.sort()
print(len(ans))
for i in ans:
	print(*i)


n = int(input())
l = list(map(int, input().split()))
g = {}
for i in set(l):
	g[i] = [-1, 0]
for i in range(n):
	if g[l[i]][0] == -1:
		g[l[i]][0] = i
	elif g[l[i]][1] == 0:
		g[l[i]][1] = i - g[l[i]][0]
		g[l[i]][0] = i
	elif g[l[i]][1] != -1:
		if i - g[l[i]][0] == g[l[i]][1]:
			g[l[i]][0] = i
		else:
			g[l[i]][1] = -1
b = []
for i in g:
	if g[i][1] != -1:
		b.append([i, g[i][1]])
b.sort(key=lambda x: x[0])
print(len(b))
for i in b:
	print(i[0], i[1])


n = int(input())
arr = [(int(x), y) for (x, y) in zip(input().split(), range(n))]
arr.sort()
res = []
a = 0
b = 0
while a < n:
	while b < n and arr[b][0] == arr[a][0]:
		b += 1
	a += 1
	if b == a:
		res.append(str(arr[a - 1][0]) + ' 0')
	else:
		diff = arr[a][1] - arr[a - 1][1]
		while a < b:
			if arr[a][1] - arr[a - 1][1] == diff:
				a += 1
			else:
				break
		if a == b:
			res.append(str(arr[a - 1][0]) + ' ' + str(diff))
	a = b
print(len(res))
print('\n'.join(res))


from operator import itemgetter

def is_prog(seq):
	if len(seq) == 1:
		return True
	else:
		d = seq[1] - seq[0]
		is_ = True
		s1 = seq[0]
		for x in range(len(seq)):
			if seq[x] != s1 + d * x:
				is_ = False
				break
		return is_

class CodeforcesTask352BSolution:

	def __init__(self):
		self.result = ''
		self.n = 0
		self.sequence = []

	def read_input(self):
		self.n = int(input())
		self.sequence = [int(x) for x in input().split(' ')]

	def process_task(self):
		xs = {}
		for x in range(1, self.n + 1):
			if self.sequence[x - 1] in xs:
				xs[self.sequence[x - 1]].append(x)
			else:
				xs[self.sequence[x - 1]] = [x]
		result = []
		for (key, value) in xs.items():
			value.sort()
			if is_prog(value):
				if len(value) > 1:
					d = value[1] - value[0]
				else:
					d = 0
				result.append((key, d))
		result.sort(key=itemgetter(0))
		self.result = '{0}\n{1}'.format(len(result), '\n'.join([' '.join([str(r) for r in x]) for x in result]))

	def get_result(self):
		return self.result
Solution = CodeforcesTask352BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


n = int(input())
l = list(map(int, input().split()))
di1 = {}
dc = {}
for i in range(n):
	if l[i] not in di1:
		di1[l[i]] = [i + 1]
		if l[i] not in dc:
			dc[l[i]] = 0
	else:
		k = abs(di1[l[i]][-1] - (i + 1))
		if dc[l[i]] == 0:
			dc[l[i]] = k
		elif dc[l[i]] != k and dc[l[i]] != 0 and (dc[l[i]] != -10):
			dc[l[i]] = -10
		di1[l[i]].append(i + 1)
ctr = 0
res = []
for i in dc:
	if dc[i] == -10:
		continue
	o = [i, dc[i]]
	res.append(o)
	ctr += 1
res = sorted(res)
print(ctr)
for i in res:
	print(i[0], i[1])


import sys
from os import path
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
n = int(input())
a = list(map(int, input().split()))
v = dict()
for i in range(n):
	x = a[i]
	if x in v:
		v[x] = [i, -1 if v[x][1] and i - v[x][0] != v[x][1] else i - v[x][0]]
	else:
		v[x] = (i, 0)
b = [(x, v[x][1]) for x in sorted(v.keys()) if v[x][1] >= 0]
print(len(b))
for (x, p) in b:
	print(x, p)


n = int(input())
lis = list(map(int, input().split()))
seen = {}

def ap(lis):
	l = abs(lis[0] - lis[1])
	for _ in range(len(lis) - 1):
		if not abs(lis[_] - lis[_ + 1]) == l:
			return False
	return True
for _ in range(n):
	if lis[_] in seen.keys():
		t = seen.get(lis[_])
		t.append(_)
	else:
		seen[lis[_]] = [_]
finall = []
for _ in sorted(seen):
	val = seen.get(_)
	if len(val) < 2:
		finall.append([_, 0])
	elif ap(val):
		finall.append([_, abs(val[0] - val[1])])
print(len(finall))
for i in range(len(finall)):
	print(*finall[i])


from sys import stdin, stdout
from os import path
rd = lambda : stdin.readline().strip()
wr = stdout.write
if path.exists('input.txt'):
	stdin = open('input.txt', 'r')
import time, math
from collections import defaultdict

def getDiff(arr):
	diff = arr[1] - arr[0]
	for i in range(1, len(arr)):
		if arr[i] - arr[i - 1] != diff:
			return -1
	return diff
x = int(rd())
mylist = list(map(int, rd().split()))
myDict = defaultdict(list)
for i in range(x):
	myDict[mylist[i]].append(i)
out = []
for (key, val) in myDict.items():
	if len(val) == 1:
		out.append((key, 0))
	elif len(val) == 2:
		out.append((key, val[1] - val[0]))
	else:
		diff = getDiff(val)
		if diff != -1:
			out.append((key, diff))
out.sort()
print(len(out))
if len(out) != 0:
	for (key, val) in out:
		print(key, val)


n = int(input())
a = list(map(int, input().split()))
lastSeen = {}
dis = {}
for i in range(n):
	if a[i] in dis and dis[a[i]] == -1:
		continue
	if a[i] in lastSeen:
		if a[i] in dis:
			if i - lastSeen[a[i]] != dis[a[i]]:
				dis[a[i]] = -1
		else:
			dis[a[i]] = i - lastSeen[a[i]]
	lastSeen[a[i]] = i
else:
	ct = 0
	allNums = sorted(lastSeen.keys())
	for num in allNums:
		if num in dis:
			if dis[num] != -1:
				ct += 1
		else:
			ct += 1
	print(ct)
	for num in allNums:
		if num in dis:
			if dis[num] != -1:
				print(num, dis[num])
		else:
			print(num, 0)


def arr_inp():
	return [int(x) for x in input().split()]

def diff(x, y):
	arr.append(y - x)
	return y
from collections import *
from functools import *
(n, a, mem, out) = (int(input()), arr_inp(), defaultdict(list), [])
for i in range(n):
	mem[a[i]].append(i)
for (i, j) in mem.items():
	arr = []
	if len(j) < 2:
		arr.append(0)
	else:
		reduce(diff, j)
		if min(arr) != max(arr):
			continue
	out.append([i, arr[0]])
print(len(out))
for (i, j) in sorted(out):
	print(i, j)


n = int(input())
a = [int(x) for x in input().split()]
d = {}
for i in range(n):
	if a[i] not in d:
		d[a[i]] = [i]
	else:
		d[a[i]].append(i)
ans = []
c = 0
for i in d:
	l = len(d[i])
	if l == 1:
		dif = 0
		ans.append([i, dif])
		c += 1
	elif l == 2:
		dif = d[i][1] - d[i][0]
		ans.append([i, dif])
		c += 1
	else:
		f = 0
		for j in range(l - 2):
			if d[i][j + 1] - d[i][j] != d[i][j + 2] - d[i][j + 1]:
				f = 1
				break
		if f == 0:
			dif = d[i][1] - d[i][0]
			ans.append([i, dif])
			c += 1
print(c)
ans.sort(key=lambda x: x[0])
for i in ans:
	print(*i)


n = int(input())
a = list(map(int, input().split()))
d = {}
for i in range(n):
	try:
		d[a[i]].append(i)
	except:
		d[a[i]] = [i]
ans = []

def ap(a):
	if len(a) == 1:
		return (True, 0)
	d = a[1] - a[0]
	for i in range(len(a)):
		if a[i] != a[0] + i * d:
			return (False, -1)
	return (True, d)
for i in d:
	(x, y) = ap(d[i])
	if x:
		ans.append((i, y))
ans.sort()
print(len(ans))
for i in ans:
	print(i[0], i[1])


dic = {}
n = int(input())
l = [int(i) for i in input().split()]
for i in range(n):
	if dic.get(l[i], -1) == -1:
		dic[l[i]] = [i]
	else:
		dic[l[i]].append(i)
ans = {}
for (k, v) in dic.items():
	if len(v) >= 2:
		dif = v[1] - v[0]
		to_add = True
		for i in range(2, len(v)):
			if v[i] - v[i - 1] != dif:
				to_add = False
		if to_add:
			ans[k] = dif
	else:
		ans[k] = 0
print(len(ans))
ans = sorted(ans.items(), key=lambda x: x[0])
for (k, v) in ans:
	print(k, v)


from collections import defaultdict
x = input()
arr = list(map(int, input().split()))
last = defaultdict(list)
diff = defaultdict(list)
for i in set(arr):
	last[i] = -1
	diff[i] = -1
for i in range(0, len(arr)):
	if last[arr[i]] == -1:
		last[arr[i]] = i
		diff[arr[i]] = 0
	elif diff[arr[i]] == -2:
		continue
	elif i - last[arr[i]] == diff[arr[i]]:
		last[arr[i]] = i
	elif diff[arr[i]] == 0:
		diff[arr[i]] = i - last[arr[i]]
		last[arr[i]] = i
	else:
		diff[arr[i]] = -2
cou = 0
for i in diff:
	if diff[i] == -2:
		cou += 1
print(len(diff) - cou)
for i in range(0, max(arr) + 1):
	if diff[i] or diff[i] == 0:
		if diff[i] == -2:
			continue
		print(str(i) + ' ' + str(diff[i]))


from collections import defaultdict
n = int(input())
a = [int(x) for x in input().split()]
z = defaultdict(lambda : [])
an = []
for i in range(n):
	z[a[i]].append(i)
p = True
for i in set(a):
	k = len(z[i])
	if k == 1:
		an.append([i, 0])
	elif k == 2:
		an.append([i, z[i][1] - z[i][0]])
	else:
		q = z[i][1] - z[i][0]
		for j in range(2, k):
			if z[i][j] - z[i][j - 1] != q:
				p = False
		if p == False:
			p = True
		else:
			an.append([i, z[i][1] - z[i][0]])
print(len(an))
an.sort()
for i in an:
	print(i[0], i[1])


n = int(input())
a = list(map(int, input().split()))
positions = [[] for _ in range(10 ** 5 + 5)]
for i in range(n):
	positions[a[i]].append(i)
res = []
t = 0
for i in range(1, 10 ** 5 + 1):
	positions[i] = sorted(positions[i])
	l = len(positions[i])
	if l == 0:
		continue
	elif l == 1:
		t += 1
		res.append((i, 0))
	else:
		d = positions[i][1] - positions[i][0]
		flag = True
		for j in range(1, l):
			if positions[i][j] - positions[i][j - 1] != d:
				flag = False
				break
		if flag:
			t += 1
			res.append((i, d))
print(t)
for i in range(t):
	print(res[i][0], res[i][1])


n = int(input())
li = list(map(int, input().split()))
mp = {}
for i in range(n):
	if li[i] not in mp:
		mp[li[i]] = [i, 0]
	elif mp[li[i]][1] == 0:
		mp[li[i]][1] = i - mp[li[i]][0]
		mp[li[i]][0] = i
	elif mp[li[i]][1] == -1:
		continue
	elif mp[li[i]][1] == i - mp[li[i]][0]:
		mp[li[i]][0] = i
	else:
		mp[li[i]][1] = -1
cnt = 0
for i in mp.values():
	if i[1] != -1:
		cnt += 1
print(cnt)
if cnt != 0:
	for (i, j) in sorted(mp.items()):
		if j[1] != -1:
			print(i, j[1])


n = int(input())
l = list(map(int, input().split()))
nex = [-1] * 100001
period = [-1] * 100001
fail = [-1] * 100001
for i in range(n):
	c = nex[l[i]]
	if c == -1:
		nex[l[i]] = i
	else:
		p = period[l[i]]
		if p == -1:
			period[l[i]] = i - c
		elif p != i - c:
			fail[l[i]] = 0
		nex[l[i]] = i
ans = 0
anss = []
for i in range(1, 100001):
	if fail[i] != 0 and nex[i] != -1 and (period[i] != -1):
		anss.append([l[nex[i]], period[i]])
		ans += 1
	elif fail[i] != 0 and nex[i] != -1 and (period[i] == -1):
		anss.append([l[nex[i]], 0])
		ans += 1
print(ans)
for i in range(ans):
	print(*anss[i])


n = int(input())
numbers = list(map(int, input().split(' ')))
no_dict = {}
for (ind, i) in enumerate(numbers):
	if i in no_dict:
		no_dict[i].append(ind + 1)
	else:
		no_dict[i] = [ind + 1]
fin_list = []
for item in sorted(no_dict):
	length = len(no_dict[item])
	if length == 1:
		fin_list.append((item, 0))
		continue
	d = no_dict[item][1] - no_dict[item][0]
	flag = True
	for i in range(2, len(no_dict[item])):
		if no_dict[item][i] - no_dict[item][i - 1] != d:
			flag = False
			break
	if flag:
		fin_list.append((item, d))
print(len(fin_list))
for tuple in fin_list:
	print(tuple[0], tuple[1])


import sys
from collections import Counter

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
n = int(input())
a = list(map(int, input().split()))
v = dict()
for i in range(n):
	x = a[i]
	if x in v:
		v[x] = [i, -1 if v[x][1] and i - v[x][0] != v[x][1] else i - v[x][0]]
	else:
		v[x] = (i, 0)
b = [(x, v[x][1]) for x in sorted(v.keys()) if v[x][1] >= 0]
print(len(b))
for (x, p) in b:
	print(x, p)


import sys
import math
import collections
import bisect
from collections import deque as queue

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(1):
	n = int(input())
	arr = get_list()
	counter = dict()
	for i in range(n):
		if arr[i] in counter:
			counter[arr[i]].append(i + 1)
		else:
			counter[arr[i]] = [i + 1]
	ans = []
	for i in counter:
		number = counter[i]
		if len(number) == 1:
			ans.append([i, 0])
		elif len(number) == 2:
			ans.append([i, number[1] - number[0]])
		else:
			broken = 0
			for j in range(len(number) - 2):
				if number[j + 2] - number[j + 1] != number[j + 1] - number[j]:
					broken += 1
					break
			if broken == 0:
				ans.append([i, number[1] - number[0]])
	ans.sort()
	print(len(ans))
	for i in ans:
		print(*i)


n = int(input())
arr = list(map(int, input().split()))
d = {}
for i in range(n):
	if arr[i] not in d:
		d[arr[i]] = [i]
	else:
		d[arr[i]].append(i)
ans = []
for (i, j) in d.items():
	if len(j) == 1:
		ans.append((i, 0))
	else:
		s = set()
		for k in range(1, len(j)):
			s.add(j[k] - j[k - 1])
		if len(s) == 1:
			ans.append((i, s.pop()))
ans = sorted(ans, key=lambda x: x[0])
print(len(ans))
for i in ans:
	print(*i)


import sys
from collections import defaultdict
input = lambda : sys.stdin.readline().strip('\r\n')
n = int(input())
a = list(map(int, input().split()))
d = defaultdict(list)
cnt = 0
ans = []
for i in range(n):
	d[a[i]].append(i)
for item in d:
	if len(d[item]) == 1:
		cnt += 1
		ans.append((item, 0))
	else:
		diff = d[item][1] - d[item][0]
		for i in range(len(d[item]) - 1):
			if d[item][i + 1] - d[item][i] != diff:
				break
		else:
			cnt += 1
			ans.append((item, diff))
ans.sort()
print(cnt)
for i in range(cnt):
	print(ans[i][0], ans[i][1])


import sys

def Is_arth(L):
	D = L[1] - L[0]
	p = L[1]
	for i in range(2, len(L)):
		if L[i] - p != D:
			return False
		p = L[i]
	return True
n = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
T = [False] * (10 ** 5 + 1)
Z = []
for i in range(10 ** 5 + 1):
	Z.append([])
Taken = []
for i in range(n):
	Z[A[i]] += [i]
Ans = ''
Num = 0
for i in range(10 ** 5 + 1):
	L = len(Z[i])
	item = i
	if L == 0:
		continue
	if L == 1:
		Num += 1
		Ans += str(item) + ' 0\n'
	elif L == 2:
		Num += 1
		Ans += str(item) + ' ' + str(Z[item][1] - Z[item][0]) + '\n'
	elif Is_arth(Z[item]):
		Num += 1
		Ans += str(item) + ' ' + str(Z[item][1] - Z[item][0]) + '\n'
sys.stdout.write(str(Num) + '\n')
sys.stdout.write(Ans)


from sys import stdin, stdout
from os import path
rd = lambda : stdin.readline().strip()
wr = stdout.write
if path.exists('input.txt'):
	stdin = open('input.txt', 'r')
from collections import defaultdict
x = int(rd())
y = list(map(int, rd().split()))
amr = defaultdict(list)
for i in range(x):
	amr[y[i]].append(i)
out = []
for (key, val) in amr.items():
	if len(val) == 1:
		out.append([key, 0])
	elif len(val) == 2:
		out.append([key, val[1] - val[0]])
	else:
		temp = val[1] - val[0]
		flag = True
		for i in range(1, len(val)):
			if temp != val[i] - val[i - 1]:
				flag = False
				break
		if flag == True:
			out.append([key, temp])
out.sort()
print(len(out))
for i in out:
	print(i[0], i[1])


n = int(input())
li = list(map(int, input().split()))
res = {}
for i in range(n):
	if li[i] not in res:
		res[li[i]] = [i + 1]
	else:
		res[li[i]].append(i + 1)
c = 0
res1 = []
for i in res:
	if len(res[i]) == 1:
		c += 1
		res1.append([i, 0])
	elif sum(res[i]) == len(res[i]) * (2 * res[i][0] + (len(res[i]) - 1) * (res[i][1] - res[i][0])) / 2:
		c += 1
		res1.append([i, res[i][1] - res[i][0]])
print(c)
res1.sort()
for i in res1:
	print(*i)


import sys
inf = float('inf')
(mod, MOD) = (1000000007, 998244353)
from collections import deque, Counter, OrderedDict, defaultdict

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()

def check(A):
	length = len(A)
	if length == 1:
		return 0
	if length == 2:
		return A[1] - A[0]
	initially = A[1] - A[0]
	for i in range(1, length):
		if A[i] - A[i - 1] != initially:
			return inf
	return initially
n = int(input())
Arr = get_array()
mydict = defaultdict(list)
for i in range(n):
	mydict[Arr[i]].append(i + 1)
ans = 0
store = []
for i in mydict:
	result = check(mydict[i])
	if result == inf:
		continue
	else:
		store.append([i, result])
		ans += 1
print(ans)
store.sort()
for i in store:
	print(*i)


n = int(input())
a = [int(x) for x in input().split()]
s = {}
for i in range(n):
	if not a[i] in s.keys():
		s[a[i]] = [i]
	else:
		s[a[i]].append(i)
for e in sorted(s.keys()):
	j = 1
	r = 0
	while j <= len(s[e]) - 2:
		if s[e][j] - s[e][j - 1] != s[e][j + 1] - s[e][j]:
			s.pop(e)
			break
		else:
			r = s[e][j + 1] - s[e][j]
		j += 1
	if e in s.keys():
		if len(s[e]) == 2:
			s[e] = s[e][1] - s[e][0]
		else:
			s[e] = r
print(len(s))
for e in sorted(s.keys()):
	print(e, s[e])


n = int(input())
numsIndexes = {}
invalidNums = set()
for (idx, x) in enumerate(input().split()):
	num = int(x)
	if num in numsIndexes:
		if numsIndexes[num]['count'] == 1:
			numsIndexes[num]['diff'] = idx - numsIndexes[num]['currentIdx']
		if idx - numsIndexes[num]['currentIdx'] == numsIndexes[num]['diff']:
			numsIndexes[num]['currentIdx'] = idx
			numsIndexes[num]['count'] += 1
		else:
			del numsIndexes[num]
			invalidNums.add(num)
	elif num not in invalidNums:
		numsIndexes[num] = {'count': 1, 'currentIdx': idx, 'diff': 0}
print(len(numsIndexes))
for num in sorted(numsIndexes.keys()):
	print(f"{num} {numsIndexes[num]['diff']}")


n = int(input())
arr = list(map(int, input().split()))
dic = {}
for i in range(n):
	if arr[i] not in dic:
		dic[arr[i]] = [i]
	else:
		dic[arr[i]].append(i)
count = 0
lst = []
for k in dic:
	check = 0
	l = len(dic[k])
	if l == 1:
		lst.append([k, 0])
		count += 1
	else:
		d = dic[k][1] - dic[k][0]
		for c in range(1, l):
			if dic[k][c] - dic[k][c - 1] != d:
				check = 1
				break
		if check == 0:
			lst.append([k, d])
			count += 1
print(count)
lst.sort()
for i in lst:
	print(*i)


a = int(input())
seq = list(map(int, input().split()))
mass = {}
for i in range(a):
	if seq[i] in mass:
		mass[seq[i]].append(i)
	else:
		mass[seq[i]] = [i]
tmp_mass = []
for (key, value) in list(mass.items()):
	flag = True
	if len(value) == 1:
		tmp_mass.append((key, 0))
		continue
	elif len(value) == 2:
		tmp_mass.append((key, value[1] - value[0]))
		continue
	else:
		for i in range(len(value) - 2):
			if value[i + 2] - value[i + 1] == value[i + 1] - value[i]:
				pass
			else:
				flag = False
		if flag:
			tmp_mass.append((key, value[len(value) - 1] - value[len(value) - 2]))
print(len(tmp_mass))
tmp_mass.sort(key=lambda x: x[0])
for i in range(len(tmp_mass)):
	print(' '.join(map(str, tmp_mass[i])))


n = int(input())
arr = list(map(int, input().split()))
ans = {}
loc = {}
l = []
for i in range(n):
	if loc.__contains__(arr[i]):
		diff = i - loc[arr[i]]
		if ans[arr[i]] == 0:
			ans[arr[i]] = diff
			loc[arr[i]] = i
		elif ans[arr[i]] == diff:
			loc[arr[i]] = i
		else:
			ans[arr[i]] = -1
			l.append(arr[i])
	else:
		loc[arr[i]] = i
		ans[arr[i]] = 0
for i in set(l):
	del ans[i]
if len(ans) > 0:
	sor = sorted(ans.items(), key=lambda x: x[0])
	print(len(sor))
	for i in sor:
		print(*i)
else:
	print(0)


n = int(input())
l = list(map(int, input().split()))
d = {}
for i in range(n):
	if l[i] in d:
		d[l[i]].append(i)
	else:
		d[l[i]] = [i]
c = 0
t = []
h = list(d.keys())
h.sort()
for i in h:
	x = d[i]
	length = len(x)
	if length == 1:
		c += 1
		t.append((i, 0))
	elif length == 2:
		c += 1
		t.append((i, x[1] - x[0]))
	else:
		flag = True
		for j in range(2, length):
			if x[j] - x[j - 1] != x[j - 1] - x[j - 2]:
				flag = False
		if flag:
			c += 1
			t.append((i, x[1] - x[0]))
print(c)
for i in t:
	print(i[0], i[1])


_ = input()
numbers = {}
for (index, num) in enumerate(input().split()):
	num = int(num)
	try:
		numbers[num].append(index)
	except:
		numbers[num] = [index]
temp = {}
size = 0
for (num, ind) in numbers.items():
	try:
		prog = ind[1] - ind[0]
	except IndexError:
		temp[num] = 0
		size += 1
		continue
	for i in range(2, len(ind)):
		new_prog = ind[i] - ind[i - 1]
		if new_prog != prog:
			prog = -1
			break
	if prog != -1:
		temp[num] = prog
		size += 1
print(size)
keys = sorted(temp.keys())
for key in keys:
	print(key, temp[key])


from collections import defaultdict
n = int(input())
l = list(map(int, input().split()))
d = defaultdict()
for i in range(n):
	m = l[i]
	if m in d:
		d[m] = (i, -1 if d[m][1] and i - d[m][0] != d[m][1] else i - d[m][0])
	else:
		d[m] = (i, 0)
s = [(i, d[i][1]) for i in sorted(d.keys()) if d[i][1] >= 0]
print(len(s))
for i in s:
	print(i[0], i[1])


import sys, math
from collections import deque, defaultdict
import operator as op
from functools import reduce
I = sys.stdin.readline

def ii():
	return int(I().strip())

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

def mi():
	return map(int, I().strip().split())

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def valid(row, col, rows, cols, rcross, lcross):
	return rows[row] == 0 and cols[col] == 0 and (rcross[col + row] == 0) and (lcross[col - row] == 0)

def div(n):
	tmp = []
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			cnt = 0
			while n % i == 0:
				n = n // i
				cnt += 1
			tmp.append((i, cnt))
	if n > 1:
		tmp.append((n, 1))
	return tmp

def isPrime(n):
	if n <= 1:
		return False
	elif n <= 2:
		return True
	else:
		flag = True
		for i in range(2, int(n ** 0.5) + 1):
			if n % i == 0:
				flag = False
				break
		return flag

def s(b):
	ans = []
	while b > 0:
		tmp = b % 10
		ans.append(tmp)
		b = b // 10
	return ans

def main():
	n = ii()
	arr = li()
	d = defaultdict(list)
	for i in range(n):
		if len(d[arr[i]]) == 0:
			d[arr[i]] = [i, 0, 255]
		elif d[arr[i]][1] == 0:
			d[arr[i]][1] = i
		else:
			fst = d[arr[i]][0]
			last = d[arr[i]][1]
			if i - last != last - fst:
				d[arr[i]][2] = 404
			else:
				d[arr[i]][0] = last
				d[arr[i]][1] = i
	ans = []
	for i in d:
		if d[i][2] == 255:
			if d[i][1] == 0:
				ans.append((i, 0))
			else:
				ans.append((i, d[i][1] - d[i][0]))
	ans = sorted(ans, key=lambda x: x[0])
	print(len(ans))
	for i in ans:
		print(*i)
main()


def ap(arr, n):
	if n == 1:
		return 0
	d = arr[1] - arr[0]
	for i in range(2, n):
		if arr[i] - arr[i - 1] != d:
			return -1
	return d
n = int(input())
a = list(map(int, input().split()))
m = list(set(a))
m.sort()
d = {}
for i in m:
	d[i] = []
for i in range(len(a)):
	d[a[i]].append(i)
c = 0
z = []
for i in m:
	x = ap(d[i], len(d[i]))
	if x != -1:
		z.append([i, x])
		c += 1
print(c)
for i in z:
	print(*i)


import atexit
import io
import sys
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__()
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

def main():
	n = int(_INPUT_LINES[0])
	l = list(map(int, _INPUT_LINES[1].split()))
	oi = 0
	prev = [-1] * 100005
	dist = [-1] * 100005
	can = [1] * 100005
	out = [0] * 100005
	for i in range(n):
		if prev[l[i]] == -1:
			prev[l[i]] = i
			dist[l[i]] = 0
		elif dist[l[i]] == 0:
			dist[l[i]] = i - prev[l[i]]
			prev[l[i]] = i
		else:
			d = i - prev[l[i]]
			if d == dist[l[i]]:
				prev[l[i]] = i
			else:
				can[l[i]] = 0
	for i in range(n):
		if can[l[i]] == 1:
			can[l[i]] = 0
			out[oi] = l[i]
			oi += 1
	if oi > 0:
		out = out[:oi]
	out.sort()
	print(oi)
	for i in range(oi):
		print(out[i], dist[out[i]])
main()


n = int(input())
arr = list(map(int, input().split()))
temp = {}
for i in range(n):
	if arr[i] not in temp:
		temp[arr[i]] = []
	temp[arr[i]].append(i)
ans = []
for i in sorted(temp.keys()):
	if len(temp[i]) < 2:
		ans.append((i, 0))
	elif len(temp[i]) == 2:
		ans.append((i, temp[i][1] - temp[i][0]))
	else:
		d = temp[i][1] - temp[i][0]
		flg = True
		for j in range(2, len(temp[i])):
			if temp[i][j] - temp[i][j - 1] != d:
				flg = False
				break
		if flg:
			ans.append((i, d))
print(len(ans))
for i in ans:
	print(*i)


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
d = defaultdict(list)
for (i, v) in enumerate(a):
	d[v].append(i)
res = []
for (k, s) in d.items():
	if len(s) == 1:
		res.append([k, 0])
	else:
		t = set((s[i + 1] - s[i] for i in range(len(s) - 1)))
		if len(t) == 1:
			res.append([k, t.pop()])
print(len(res))
res = sorted(res, key=lambda x: x[0])
for (p, q) in res:
	print(p, q)


n = int(input())
a = list(map(int, input().split(' ')))
d = dict()
for (i, x) in enumerate(a):
	if x not in d:
		d[x] = []
	d[x].append(i)
ans = dict()
for k in d:
	b = d[k]
	if len(b) == 1:
		ans[k] = 0
		continue
	diff = b[1] - b[0]
	fail = 0
	for i in range(len(b) - 1):
		if b[i + 1] - b[i] != diff:
			fail = 1
	if not fail:
		ans[k] = diff
print(len(ans.keys()))
s = []
for k in ans:
	s.append([k, ans[k]])
s.sort()
for [x, y] in s:
	print(x, y)


n = int(input())
arr = [int(i) for i in input().split()]
dic = {}
r = {}
for i in range(n):
	if arr[i] in r:
		continue
	if arr[i] not in dic and arr[i] not in r:
		dic[arr[i]] = [0, i]
	elif i - dic[arr[i]][1] != dic[arr[i]][0] and dic[arr[i]][0] != 0:
		del dic[arr[i]]
		r[arr[i]] = 0
	else:
		dic[arr[i]][0] = i - dic[arr[i]][1]
		dic[arr[i]][1] = i
ans = []
for i in dic:
	ans.append([i, dic[i][0]])
ans.sort()
print(len(ans))
for i in ans:
	print(i[0], i[1])


n = int(input())
a = list(map(int, input().split()))
ma = {}
count = 0
for (i, ele) in enumerate(a):
	if ele not in ma:
		count += 1
		ma[ele] = [None, i, True]
	elif ma[ele][2] == True:
		if ma[ele][0] == None:
			ma[ele][0] = i - ma[ele][1]
			ma[ele][1] = i
		else:
			diff = i - ma[ele][1]
			if diff == ma[ele][0]:
				ma[ele][1] = i
			else:
				ma[ele][2] = False
				count -= 1
print(count)
for ele in sorted(ma):
	if ma[ele][2]:
		print(ele, end=' ')
		print(ma[ele][0] if ma[ele][0] is not None else 0)


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
n = iinput()
A = rlinput()
from collections import defaultdict
dict = defaultdict(list)
for i in range(n):
	dict[A[i]].append(i)
ans = []
for a in sorted(dict.keys()):
	if len(dict[a]) == 1:
		ans.append([a, 0])
	else:
		A = sorted(dict[a])
		p = A[1] - A[0]
		for i in range(2, len(A)):
			if A[i] - A[i - 1] != p:
				break
		else:
			ans.append([a, p])
print(len(ans))
for a in ans:
	print(*a)


def jeff(n, a):
	dicti = {}
	for i in range(n):
		if a[i] not in dicti:
			dicti[a[i]] = [i, 0, 0]
		elif dicti[a[i]][1] != 0:
			if dicti[a[i]][2] == i - dicti[a[i]][0]:
				dicti[a[i]][0] = i
				dicti[a[i]][1] += 1
			else:
				dicti[a[i]][2] = -1
		else:
			dicti[a[i]][2] = i - dicti[a[i]][0]
			dicti[a[i]][0] = i
			dicti[a[i]][1] += 1
	ans = {}
	for i in dicti:
		if dicti[i][2] != -1:
			ans[i] = dicti[i][2]
	return ans
n = int(input())
a = list(map(int, input().split()))
ans = jeff(n, a)
print(len(ans))
g = sorted(ans)
for i in g:
	print(str(i) + ' ' + str(ans[i]))


from sys import stdin, stdout
n = int(stdin.readline())
Ar = [int(x) for x in stdin.readline().split()]
Ar = [0] + Ar
A = {}
for i in range(1, n + 1):
	try:
		A[Ar[i]].append(i)
	except:
		A[Ar[i]] = [i]
cnt = 0
temp = []
for i in A:
	flag = 0
	if len(A[i]) > 1:
		diff = A[i][1] - A[i][0]
		for j in range(1, len(A[i])):
			if A[i][j] - A[i][j - 1] == diff:
				pass
			else:
				flag = 1
				break
		if flag == 0:
			cnt += 1
			temp.append([i, diff])
	else:
		temp.append([i, 0])
		cnt += 1
stdout.write(str(cnt) + '\n')
temp.sort()
temp2 = []
for i in temp:
	temp2.append(str(i[0]) + ' ' + str(i[1]))
if cnt:
	stdout.write('\n'.join(temp2))


n = int(input())
a = [int(i) for i in input().split()]
d = {}
check = {}
b = []
for i in range(n):
	if a[i] in d:
		if d[a[i]][1] != 0 and d[a[i]][1] != i - d[a[i]][0]:
			check[a[i]] = False
		d[a[i]] = [i, i - d[a[i]][0]]
	else:
		d[a[i]] = [i, 0]
		check[a[i]] = True
print(sum(check.values()))
for i in sorted(d):
	if check[i]:
		print(i, d[i][1])


n = int(input())
A = [int(i) for i in input().split()]
table = [None for i in range(100001)]
for (i, x) in enumerate(A):
	if table[x] == None:
		table[x] = [i, 0]
	else:
		previ = table[x][0]
		if previ == -1:
			continue
		prevp = table[x][1]
		if prevp == 0:
			table[x][0] = i
			table[x][1] = i - previ
		else:
			currentp = i - previ
			if currentp == prevp:
				table[x][0] = i
			else:
				table[x][0] = -1
output = [(x, t[1]) for (x, t) in enumerate(table) if t != None and t[0] != -1]
s = str(len(output)) + '\n'
for (x, p) in output:
	s += str(x) + ' ' + str(p) + '\n'
print(s)


n = int(input())
l = list(map(int, input().strip().split()))

def ap(a):
	if len(a) <= 2:
		return True
	else:
		first_term = a[0]
		d = a[1] - a[0]
		for i in range(2, len(a)):
			if a[i] - d != a[i - 1]:
				return False
		return True
h = {}
for i in range(0, n):
	if l[i] in h:
		h[l[i]].append(i)
	else:
		h.update({l[i]: [i]})
res = []
for key in h.keys():
	if ap(h[key]) == True:
		t = h[key]
		if len(t) == 1:
			res.append([key, 0])
		else:
			res.append([key, t[1] - t[0]])
res.sort()
print(len(res))
for j in res:
	print(*j)


n = int(input())
numsIndexes = {}
for (idx, x) in enumerate(input().split()):
	num = int(x)
	if num in numsIndexes:
		numsIndexes[num].append(idx)
	else:
		numsIndexes[num] = [idx]
results = []
for num in sorted(numsIndexes.keys()):
	indexes = numsIndexes[num]
	if len(indexes) == 1:
		result = f'{num} 0'
		results.append(result)
	else:
		answer = True
		diff = indexes[1] - indexes[0]
		for i in range(2, len(indexes)):
			if indexes[i] - indexes[i - 1] != diff:
				answer = False
				break
		if answer:
			result = f'{num} {diff}'
			results.append(result)
print(len(results))
for result in results:
	print(result)


n = int(input())
arr = list(map(int, input().split()))
ct = dict()
for i in range(n):
	if arr[i] not in ct:
		ct[arr[i]] = []
	ct[arr[i]].append(i)
for i in ct.copy():
	if len(ct[i]) == 1:
		ct[i] = 0
	else:
		m = ct[i]
		f = m[0]
		s = m[1]
		d = s - f
		ll = len(m)
		for u in range(2, ll):
			y = m[u]
			if y - s != d:
				del ct[i]
				break
			s = y
		else:
			ct[i] = d
print(len(ct))
for i in sorted(ct):
	print(i, ct[i])


import collections
n = int(input())
l = [int(i) for i in input().split()]
t = 0
d = {}
for i in range(n):
	try:
		if len(d[l[i]]) == 3:
			d[l[i]][1] = i - d[l[i]][2]
			d[l[i]] += [i]
		elif i - d[l[i]][-1] == d[l[i]][1] and d[l[i]][0] == 1:
			d[l[i]] += [i]
		else:
			if d[l[i]][0] == 1:
				t -= 1
			d[l[i]][0] = 0
	except:
		t += 1
		d[l[i]] = [1, 0, i]
print(t)
d = collections.OrderedDict(sorted(d.items()))
for i in d:
	if d[i][0] == 1:
		print(i, d[i][1])


n = int(input())
a = [int(x) for x in input().split()]
d = {}
for i in range(n):
	if a[i] in d:
		l = d[a[i]]
		l.append(i)
	else:
		d[a[i]] = [i]
anslist = []
for i in sorted(d.keys()):
	if len(d[i]) == 1:
		anslist.append((i, 0))
	else:
		diff = d[i][1] - d[i][0]
		for j in range(1, len(d[i])):
			if d[i][j] - d[i][j - 1] != diff:
				break
		else:
			anslist.append((i, diff))
print(len(anslist))
for i in anslist:
	print(i[0], i[1])


import sys
import heapq
from math import *
from collections import defaultdict as dd
from collections import deque
from collections import Counter as c
from itertools import combinations as comb
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(var)

def l():
	return list(map(int, data().split()))

def sl():
	return list(map(str, data().split()))

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [[val for i in range(n)] for j in range(m)]
n = int(data())
arr = l()
dp = dd(list)
answer = 0
result = list()
for i in range(n):
	dp[arr[i]].append(i)
for i in dp.keys():
	if len(dp[i]) == 1:
		answer += 1
		result.append((i, 0))
	else:
		d = dp[i][1] - dp[i][0]
		r = True
		for j in range(1, len(dp[i])):
			if dp[i][j] - dp[i][j - 1] != d:
				r = False
				break
		if r:
			answer += 1
			result.append((i, d))
out(str(answer) + '\n')
result = sorted(result, key=lambda x: x[0])
for i in result:
	out(str(i[0]) + ' ' + str(i[1]) + '\n')


n = int(input())
a = list(map(int, input().split()))
lans = 0
ans = []
b = []
for i in range(10 ** 5 + 1):
	b.append([])
for i in range(n):
	b[a[i]].append(i)
for i in range(10 ** 5 + 1):
	if len(b[i]) == 0:
		continue
	elif len(b[i]) == 1:
		ans.append([i, 0])
		lans += 1
	elif len(b[i]) == 2:
		ans.append([i, b[i][1] - b[i][0]])
		lans += 1
	else:
		flag = False
		d = b[i][1] - b[i][0]
		for j in range(1, len(b[i]) - 1):
			if b[i][j + 1] - b[i][j] != d:
				flag = True
				break
		if flag:
			continue
		ans.append([i, d])
		lans += 1
print(lans)
for i in range(lans):
	print(ans[i][0], ans[i][1])


n = int(input())
indices = {}
ans_set = set()
for (idx, ch) in enumerate(input().split()):
	if ch in indices:
		if not indices[ch][1] or indices[ch][1] == idx - indices[ch][0]:
			indices[ch] = (idx, idx - indices[ch][0])
		else:
			ans_set -= {ch}
	else:
		ans_set.add(ch)
		indices[ch] = (idx, 0)
print(len(ans_set))
for k in sorted(ans_set, key=int):
	print(k, indices[k][1])


import os
import sys
from io import BytesIO, IOBase

def checkarm(arr):
	arr = list(arr)
	if len(arr) == 1:
		return 0
	d = arr[1] - arr[0]
	for i in range(2, len(arr)):
		if arr[i] - arr[i - 1] == d:
			pass
		else:
			return -1
	return d

def main():
	n = int(input())
	a = list(map(int, input().split()))
	d = dict()
	for (i, item) in enumerate(a):
		if d.get(item) == None:
			d[item] = [i]
		else:
			d[item].append(i)
	ans = []
	for item in d.keys():
		temp = checkarm(d[item])
		if temp != -1:
			ans.append([item, temp])
	ans.sort(key=lambda x: x[0])
	print(len(ans))
	for item in ans:
		print(*item)

def nouse0():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse1():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse2():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
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')

def nouse3():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse4():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse5():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
main()


n = int(input())
arr = input().split()
d = {}
for i in range(n):
	if d.get(arr[i]):
		d[arr[i]].append(i)
	else:
		d[arr[i]] = [i]
pre = 0
numbers = {}
c = 0
flag = True
for (key, value) in d.items():
	for i in range(len(value) - 1):
		if pre:
			if value[i + 1] - value[i] != pre:
				flag = False
		else:
			pre = value[i + 1] - value[i]
	if flag:
		numbers[int(key)] = pre
		c += 1
	flag = True
	pre = 0
print(c)
for i in sorted(numbers.keys()):
	print(i, numbers[i])


from sys import stdin
input = stdin.readline

def periods(arr):
	dct = {}
	no = []
	for i in range(len(arr)):
		if arr[i] not in dct:
			if arr[i] not in no:
				dct[arr[i]] = [i]
		else:
			dct[arr[i]] += [i]
			if len(dct[arr[i]]) > 2:
				t = dct[arr[i]]
				if t[-1] - t[-2] != t[-2] - t[-3]:
					dct.pop(arr[i])
					no.append(arr[i])
	print(len(dct.keys()))
	for x in sorted(dct.keys()):
		y = dct[x]
		if len(y) >= 2:
			print(x, y[1] - y[0])
		else:
			print(x, 0)
	return ''
a = input().strip()
lst = list(map(int, input().strip().split()))
print(periods(lst))


import sys
from collections import defaultdict
n = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().split()))
d = defaultdict(list)
for i in range(n):
	d[arr[i]].append(i)
ans = []
for (k, v) in d.items():
	if len(v) > 1:
		diff = v[1] - v[0]
		for i in range(2, len(v)):
			if v[i] - v[i - 1] != diff:
				break
		else:
			ans.append((k, diff))
	else:
		ans.append((k, 0))
ans = sorted(ans)
print(len(ans))
for (k, diff) in ans:
	print(k, diff)