One day Jeff got hold of an integer sequence a1, a2, ..., an 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 ai = 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 ≤ 105). The next line contains integers a1, a2, ..., an (1 ≤ ai ≤ 105). 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 px, where x is current suitable value, px is the common difference between numbers in the progression (if x occurs exactly once in the sequence, px 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 p2 = 0.



import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class B {
	static StringTokenizer st;
	static BufferedReader in;
	static PrintWriter out;
	static int cnt = 0;
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		begin();
		solve();
		end();

	}

	private static void end() {
		out.close();
	}

	private static void solve() throws NumberFormatException, IOException {
		int n = Integer();
		int []arr = new int [n+1];
		
		ArrayList<Integer> []list = new ArrayList[(int) 1e5+1];
		for (int i = 0; i < list.length; i++) {
			list[i] = new ArrayList<Integer>();
		}
		for (int i = 1; i <= n; i++) {
			arr[i] = Integer();
			list[arr[i]].add(i);
		}
		ArrayList<Point> ans = new ArrayList<Point>();
		for (int i = 0; i < list.length; i++) {
			if (list[i].size() != 0){
				int cnt = 0;
				int begin = 0;
				int end = 0;
				int t = 0;
				int d = 0;
				int c = 0;
				for (int v : list[i]) {
					if (cnt == 0){
						begin = v;
						cnt++;
						continue;
					}
					end = v;
					if (end-begin != d){
						d = end-begin;
						c++;
					}
					begin = end;
				}
				
				if (c == 1){
					ans.add(new Point(i,d));
				}else if (list[i].size() == 1)
					ans.add(new Point(i,0));
			}
		}
		println(ans.size());
		for (Point p : ans) {
			println(p.x+" "+p.y);
		}
		
	}

	private static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	private static String StringLine() throws IOException {
		return in.readLine();
	}

	private static void println(Object s) {
		out.println(s);
	}

	private static void print(Object s) {
		out.print(s);
	}

	private static int Long() throws NumberFormatException, IOException {
		return (int) Long.parseLong(String());
	}

	private static int Integer() throws NumberFormatException, IOException {
		return Integer.parseInt(String());
	}

	private static String String() throws IOException {
		while (!st.hasMoreElements())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

	private static void begin() {
		out = new PrintWriter(new OutputStreamWriter(System.out));
		in = new BufferedReader(new InputStreamReader(System.in));
		st = new StringTokenizer("");
	}

}