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.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.StringTokenizer;

/**
 * @author Jens Staahl
 */

public class Prac {

	// some local config
	// static boolean test = false ;
	private boolean test = System.getProperty("ONLINE_JUDGE") == null;
	static String testDataFile = "testdata.txt";
	// static String testDataFile = "testdata.txt";
	private static String ENDL = "\n";
	public long GCD(long a, long b){   if (b==0) return a;   return GCD(b,a%b); }
	public long LCM(long a, long b) {return a * b / GCD(a, b);}
	// Just solves the acutal kattis-problem
	ZKattio io;
	private void solve() throws Throwable {
		io = new ZKattio(stream);
		int n = io.getInt();
		int[] r = new int[n];
		for (int i = 0; i < n; i++) {
			r[i] = io.getInt();
		}
		HashMap<Integer, List<Integer>> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			List<Integer> list = map.get(r[i]);
			if(list == null) {
				list = new ArrayList<>();
				map.put(r[i], list);
			}
			list.add(i);
		}
		List<Integer> keys = new ArrayList<>();
		keys.addAll(map.keySet());
		Collections.sort(keys);
		List<String> print = new ArrayList<>();
		for (int i = 0; i < keys.size(); i++) {
			Integer val = keys.get(i);
			List<Integer> list = map.get(val);
			if(list.size() ==1 ){
				print.add(val + " 0\n");
				continue;
			}
			int diff = list.get(1) - list.get(0);
			boolean ok = true;
			for (int j = 0; j < list.size()-1; j++) {
				if(list.get(j+1) - list.get(j) != diff) {
					ok = false;
				}
			}
			if(ok) {
				print.add(val + " " + diff + "\n");
			}
		}
		out.write(print.size() + "\n");
		for (int i = 0; i < print.size(); i++) {
			out.write(print.get(i));
		}
		out.close();
	}
	public static void main(String[] args) throws Throwable {
		new Prac().solve();
	}

	public Prac() throws Throwable {
		if (test) {
			stream = new FileInputStream(testDataFile);
		}
	}

	InputStream stream = System.in;
	BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));// outStream

	public class ZKattio extends PrintWriter {
		public ZKattio(InputStream i) {
			super(new BufferedOutputStream(System.out));
			r = new BufferedReader(new InputStreamReader(i));
		}

		public ZKattio(InputStream i, OutputStream o) {
			super(new BufferedOutputStream(o));
			r = new BufferedReader(new InputStreamReader(i));
		}

		public boolean hasMoreTokens() {
			return peekToken() != null;
		}

		public int getInt() {
			return Integer.parseInt(nextToken());
		}

		public double getDouble() {
			return Double.parseDouble(nextToken());
		}

		public long getLong() {
			return Long.parseLong(nextToken());
		}

		public String getWord() {
			return nextToken();
		}

		private BufferedReader r;
		private String line;
		private StringTokenizer st;
		private String token;

		private String peekToken() {
			if (token == null)
				try {
					while (st == null || !st.hasMoreTokens()) {
						line = r.readLine();
						if (line == null)
							return null;
						st = new StringTokenizer(line);
					}
					token = st.nextToken();
				} catch (IOException e) {
				}
			return token;
		}

		private String nextToken() {
			String ans = peekToken();
			token = null;
			return ans;
		}
	}
	// System.out;

}