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.
/* package whatever; // don't place package name! */
 
import java.util.*;
import java.lang.*;
import java.io.*;
 
/* Name of the class has to be "Main" only if the class is public. */
public class bbg
{
	public static int result;
 
public static ArrayList<Integer> [] graph;
 
public static int[]cats;
 
public static int vizitat[];
public static int x;
//public static HashMap<String, Integer> map2;
 
 
	public static void main (String[] args) throws java.lang.Exception
{
 
Scanner input=new Scanner(System.in);
 
HashMap<Integer, Integer> contor1= new HashMap<Integer, Integer>();
HashMap<Integer, Integer> contor2= new HashMap<Integer, Integer>();


HashMap<Integer, Integer> map= new HashMap<Integer, Integer>();
HashMap<Integer, Integer> map2= new HashMap<Integer, Integer>();
HashMap<String, Integer> combinari= new HashMap<String, Integer>();
 
		
		
	int n=input.nextInt();
	
	int v[]=new int[n];
	
		
	
	int cantitate[]=new int[100001];
	int rest[]=new int[100001];
	int pozitie[]=new int[100001];
	
	int y=1;
	
	
	for(int i=0;i<n;i++) 
	
	{
	v[i]=input.nextInt();
	
	cantitate[v[i]]++;
	
//	System.out.println("1)   "+i+" "+v[i]+" cantitate="+cantitate[v[i]]+" rest="+rest[v[i]]+" pozitie="+pozitie[v[i]]);
	
	
	if(rest[v[i]]!=-1)
	{
	
	if(cantitate[v[i]]==2 ) rest[v[i]]=i-pozitie[v[i]];
	
else	if(cantitate[v[i]]>2 )
	
	{
	  //  int part=i-rest[i];
	 
	  
	if(i-pozitie[v[i]]!=rest[v[i]])
	
	{rest[v[i]]=-1; map.remove(v[i]);}
	

	

	}
	
	
	}
	
	//	if(cantitate[v[i]]>0 && rest[v[i]]==-1){ map.remove(v[i]);
		
		//	System.out.println("exclus "+v[i]+" "+rest[v[i]]);
		
		
			if(cantitate[v[i]]>0 && rest[v[i]]>-1)
			
			{ map.put(v[i],rest[v[i]]);
		
		}
	
	
	
	
	
	
	
	pozitie[v[i]]=i;
	
	}
	
	
	
//	System.out.println("2)  "+i+" "+v[i]+" "+cantitate[v[i]]+" "+rest[v[i]]+" "+pozitie[v[i]]);
	
	
	
	
	
	
	
		//System.out.println(cantitate[1]);
	
//	System.out.println(rest[1]);
	
	int contor=0;
	

	
	System.out.println(map.size());
	

	StringBuilder rez=new StringBuilder("");
	
	Arrays.sort(v);
	
	for(int i=0;i<v.length;i++)
	if(map.containsKey(v[i])) {
	    
	    rez.append(String.valueOf(v[i]));
	    rez.append(" ");
	    rez.append(String.valueOf(map.get(v[i])));
	    rez.append("\n");
	    
	  //  System.out.println(v[i]+" "+map.get(v[i]));
	
	map.remove(v[i]);
	
	}
	
	System.out.println(rez);
	
	
	
	
	
	
	
	
	
		
	
		}
		
		
		}