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.*;
import java.util.*;


public class CF {
	
	
	

	
	static class Pair{
	long x,y;
	public Pair(long a, long b) {
		this.x=a;
		this.y=b;
	}
	}
	
	static class sortByProfit implements Comparator<Pair>{
		
		@Override 
		public int compare(Pair a, Pair b) {
			
			
				if(a.x!=b.x) {
					return (int)(a.x-b.x);
				}
				else {
					return (int)(b.y-a.y);
				}
			
			
		}
	}


	static class in {
	    static BufferedReader reader;
	    static StringTokenizer tokenizer;

	    /** call this method to initialize reader for InputStream */
	    static void init(InputStream input) {
	        reader = new BufferedReader(
	                     new InputStreamReader(input) );
	        tokenizer = new StringTokenizer("");
	    }

	    /** get next word */
	    static String next() throws IOException {
	        while ( ! tokenizer.hasMoreTokens() ) {
	            //TODO add check for eof if necessary
	            tokenizer = new StringTokenizer(
	                   reader.readLine() );
	        }
	        return tokenizer.nextToken();
	    }

	    static int nextInt() throws IOException {
	        return Integer.parseInt( next() );
	    }
		
	    static double nextDouble() throws IOException {
	        return Double.parseDouble( next() );
	    }
	    static long nextLong() throws IOException {
	        return Long.parseLong( next() );
	    }
	}
	
	public static int[] ini(int n)throws IOException {
		
		int[] arr=new int[n];
		for(int i=0;i<n;i++) {
			arr[i]=in.nextInt();
		}
		return arr;
		
	}
	
	public static long[] inl(int n)throws IOException {
		
		long[] arr=new long[n];
		for(int i=0;i<n;i++) {
			arr[i]=in.nextLong();
		}
		return arr;
		
	}
	
	public static int gcd(int a, int b) {
		if(b==0) {
			return a;
		}
		return gcd (b,a%b);
	}
	public static long gcd(long a, long b) {
		if(b==0) {
			return a;
		}
		return gcd (b,a%b);
	}
	public static int lcm(int a, int b) {
		return (a*b)/gcd(a,b);
	}
	public static int max(int[] arr) {
		int max=Integer.MIN_VALUE;
		for(int i=0;i<arr.length;i++) {
			max=Math.max(max, arr[i]);
		}
		return max;
	}
	
	public static long max(long[] arr) {
		long max=Long.MIN_VALUE;
		for(int i=0;i<arr.length;i++) {
			max=Math.max(max, arr[i]);
		}
		return max;
	}
	public static int min(int[] arr) {
		int min=Integer.MAX_VALUE;
		for(int i=0;i<arr.length;i++) {
			min=Math.min(min, arr[i]);
		}
		return min;
	}
	
	public static long min(long[] arr) {
		long min=Long.MAX_VALUE;
		for(int i=0;i<arr.length;i++) {
			min=Math.min(min, arr[i]);
		}
		return min;
	}
	
	public static void reverse(int[] arr, int low, int high) {
		
		int temp;
        while (low<high) {
            temp = arr[low];
            arr[low] = arr[high];
            arr[high] = temp;
            low++;
            high--;
        }
		
	}
	public static void reverse(long[] arr, int low, int high) {
		
		long temp;
        while (low<high) {
            temp = arr[low];
            arr[low] = arr[high];
            arr[high] = temp;
            low++;
            high--;
        }
		
	}
	public static int binarySearch(int arr[], int l, int r, int x)
    {
        if (r >= l) {
            int mid = l + (r - l) / 2;
  
            if (arr[mid] == x)
            	return mid;
           
            if (arr[mid] > x)
                return binarySearch(arr, l, mid - 1, x);
  
            return binarySearch(arr, mid + 1, r, x);
        }

        return -1;
    }
	
	public static void swap(char[] arr, int i, int j) {
		
		char x=arr[i];
		arr[i] = arr[j];
		arr[j] = x;
	}
	
	
	
	public static int sum(int[] arr) {
		
		
		int sum=0;
		int n  =arr.length;
				
		for(int i=0;i<n;i++) {
			sum+=arr[i];
		}
		
		return sum;
	}
	
	
	public static ArrayList<Integer> sieveOfEratosthenes(int n)
    {
        boolean prime[] = new boolean[n + 1];
        for (int i = 0; i <= n; i++)
            prime[i] = true;
 
        for (int p = 2; p * p <= n; p++)
        {
           
            if (prime[p] == true)
            {
                
                for (int i = p * p; i <= n; i += p)
                    prime[i] = false;
            }
        }

       ArrayList<Integer> lol=new ArrayList<Integer>();
       
       for(int i=2;i<=n;i++) {
    	   if(prime[i] ==true) {
    		   lol.add(i);
    	   }
       }
       
       return lol;
    }
	
	
	
	
	
	static boolean isPrime(int n)
    {
    
        if (n <= 1) return false;
     
        
        for (int i = 2; i < Math.sqrt(n); i++)
            if (n % i == 0)
                return false;
     
        return true;
    }

	
	
	
	
	
	
	
	/**************************************************************************************/
	
	static int countDigit(long  n)
	{
	    int count = 0;
	    while (n != 0)
	    {
	        n = n / 10;
	        ++count;
	    }
	    return count;
	}
	
	
	
	public static void solve() {
		
	}
	
	public static void merge(int[] s1, int[] s2, int[] des){
        
        int i=0;
        int j=0;
        int k=0;
        
        while(i<s1.length && j<s2.length){
            if(s1[i]<=s2[j]){
                des[k]=s1[i];
                i++;
            }
            
            else{
                des[k]=s2[j];
                j++;
            }
            k++;
        }
        
        if(i<s1.length){
            while(i<s1.length){
                des[k]=s1[i];
                i++;
                k++;
            }
        }
        if(j<s2.length){
            while(j<s2.length){
                des[k]=s2[j];
                j++;
                k++;
            }
        }
        
    }

    public static void mergeSort(int[] input){
        
        
        // Write your code here
       if(input.length<=1){
           return;
       }
        
        int[] s1=new int[input.length/2];
        int[] s2=new int[input.length-s1.length];
        
        for(int i=0;i<s1.length;i++){
            s1[i]=input[i];
        }
        
        for(int i=s1.length;i<input.length;i++){
            s2[i-s1.length]=input[i];
        }
        
        mergeSort(s1);
        mergeSort(s2);
        merge(s1,s2,input);
        
        
        
        
    }
	
	
	
	

	public static void main(String[] args)throws IOException {
		// TODO Auto-generated method stub
		in.init(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		
		int n=in.nextInt();
		
		HashMap<Integer, Integer> ans=new HashMap<Integer, Integer>();
		
		HashMap<Integer, ArrayList<Integer>> lol=new HashMap<>();
				
		for(int i=0;i<n;i++) {
			
			int x=in.nextInt();
			
			if(lol.containsKey(x) && !ans.containsKey(x) ){
				
				ArrayList<Integer> temp=lol.get(x);
				
				temp.add(i);
				if(temp.size()>2) {
					
					
					int check1= temp.get(temp.size() -2);
					int check2 = temp.get(temp.size() -3);
					
					if((i-check1)==(check1-check2)) {
						
						continue;
					}
					else {
						ans.put(x, -1);
					}
						
					
				}
				
				
			}
			
			else if(!ans.containsKey(x)){
				
				ArrayList<Integer> kk=new ArrayList<Integer>();
				kk.add(i);
				lol.put(x,kk);
			}
			
			
		}
		
		
		for(int j: lol.keySet()) {
			
			
			if(lol.get(j).size() == 1 ) {
				ans.put(j, 0);
			}
			
			else if(!ans.containsKey(j)) {
				
				ans.put(j, lol.get(j).get(1) - lol.get(j).get(0));
			}
			
		}
		
		TreeMap<Integer, Integer> ham=new TreeMap<>(ans);
		int count=0;
		for(int p: ham.keySet()) {
			
			int lol2=ham.get(p);
			if(lol2!=-1) {
				count++;
			}
		}
		pw.println(count);
		for(int p: ham.keySet()) {
			
			int lol2=ham.get(p);
			if(lol2!=-1) {
				pw.println(p+" "+lol2);
			}
		}
		
		pw.flush();
		
		pw.close();
		
	}
	
}
