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.
/*input
3
1 10 5
*/
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	static PrintWriter out;
	static int MOD = 1000000007;
     /*-------- for output ---------------------*/
     static void iPA(int arr []){
     	 StringBuilder output = new StringBuilder();
	     for(int i=0; i<arr.length; i++)output.append(arr[i] + " ");System.out.println(output);
	}
	static void lPA(long arr []){
	     StringBuilder output = new StringBuilder();
	     for(int i=0; i<arr.length; i++)output.append(arr[i] + " ");System.out.println(output);
	}
	static void sPA(String arr []){
	     StringBuilder output = new StringBuilder();
	     for(int i=0; i<arr.length; i++)output.append(arr[i] + " ");System.out.println(output);
	}
	static void dPA(double arr []){
	     StringBuilder output = new StringBuilder();
	     for(int i=0; i<arr.length; i++)output.append(arr[i] + " ");System.out.println(output);
	}
    /*-------------- for input ---------------------*/
	static void iIA(FastReader reader, int arr[]){
	     for(int i=0; i<arr.length; i++)arr[i] = reader.nextInt(); 
	}
	static void lIA(FastReader reader, long arr[]){
	     for(int i=0; i<arr.length; i++)arr[i] = reader.nextLong(); 
	}
	static void sIA(FastReader reader, String arr[]){
	     for(int i=0; i<arr.length; i++)arr[i] = reader.next(); 
	}
	static void dIA(FastReader reader, double arr[]){
	     for(int i=0; i<arr.length; i++)arr[i] = reader.nextDouble();
	}
	/*------------ for taking input faster ----------------*/
     static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
		{
			return Integer.parseInt(next());
		}

		long nextLong()
		{
			return Long.parseLong(next());
		}

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}

	// Method to check if x is power of 2
    static boolean isPowerOfTwo (int x) 
    { 
        return x!=0 && ((x&(x-1)) == 0);     
    }
    //Method to return lcm of two numbers
    static int gcd(int a, int b)
    {
        return a==0?b:gcd(b % a, a); 
    }
    // method to return LCM of two numbers
    static int lcm(int a, int b)
    {
        return (a / gcd(a, b)) * b;
    }
    //Method to find the max in an array
    public static int getMax(int arr[]){
    	int max = arr[0];
    	for(int i=0; i<arr.length; i++){
    		max = arr[i]>max?arr[i]:max;
    	}
    	return max;
    }
    //Method to find the min in an array
    public static int getMin(int arr[]){
    	int min = arr[0];
    	for(int i=0; i<arr.length; i++){
    		min = min>arr[i]?arr[i]:min;
    	}
    	return min;
    }
    private static int countDigits(long l) {
			if (l >= 1000000000000000000L) return 19;
			if (l >= 100000000000000000L) return 18;
			if (l >= 10000000000000000L) return 17;
			if (l >= 1000000000000000L) return 16;
			if (l >= 100000000000000L) return 15;
			if (l >= 10000000000000L) return 14;
			if (l >= 1000000000000L) return 13;
			if (l >= 100000000000L) return 12;
			if (l >= 10000000000L) return 11;
			if (l >= 1000000000L) return 10;
			if (l >= 100000000L) return 9;
			if (l >= 10000000L) return 8;
			if (l >= 1000000L) return 7;
			if (l >= 100000L) return 6;
			if (l >= 10000L) return 5;
			if (l >= 1000L) return 4;
			if (l >= 100L) return 3;
			if (l >= 10L) return 2;
			return 1;
		}



	public static void main (String[] args) throws java.lang.Exception
	{
		OutputStream outputStream =System.out;
        out =new PrintWriter(outputStream);
        FastReader sc =new FastReader();
		//for fast output sometimes
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int arr[] = new int[n];
		iIA(sc, arr);
		int recent[] = new int[100001];
		Arrays.fill(recent, -1);
		int r[] = new int[100001];
		Arrays.fill(r, -1);
		//boolean check [] = new boolean[100001];
		//Arrays.fill(check, false);
		for(int i=0; i<n; i++){
		   if(recent[arr[i]] == -5)
		   	continue;
           if(recent[arr[i]] == -1){
           	recent[arr[i]] = i;
            r[arr[i]] = 0;
           }
           else{
           	int val = i - recent[arr[i]];
           	//out.println(val);
           	if(r[arr[i]] == 0){
           		recent[arr[i]] = i;
           		r[arr[i]] = val;
           	}
           	else{
           		if(r[arr[i]] != val)
           			recent[arr[i]] = -5;
           		else
           			recent[arr[i]] = i;
           	}
           }
		}
		int count=0;
		for(int i=0; i<100001; i++){
			//if(i<=10)
			//out.print(recent[i] + " ");
			if(recent[i]>=0){
				count++;
				sb.append(i + " " + r[i] + "\n");
			}
		}
		out.println(count);
		out.println(sb);
		out.close();
	}
	
}
