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

public class First
{
    
    public static void process()throws IOException
    {

            int n = ni();
 
        List<Integer> list[] = new ArrayList[100000+1];
 
        for(int i=1;i<=100000;i++){
            list[i] = new ArrayList<>();
        }
        TreeSet<Integer> set = new TreeSet<>();
 
        for(int i=0;i<n;i++){
            int a = ni();
 
            if(set.contains(a)){
                list[a].add(i);
            }
            else{
                set.add(a);
                list[a].add(i);
            }
        }
 
        Iterator<Integer> it = set.iterator();
        List<String> ans = new ArrayList<>();
 
        while (it.hasNext()){
            int a = it.next();
 
            if(list[a].size()==1){
 
                ans.add(Integer.toString(a)+" 0");
            }
            else if(list[a].size()==2){
                int diff = Math.abs(list[a].get(0)-list[a].get(1));
 
                ans.add(Integer.toString(a)+" "+Integer.toString(diff));
            }
            else{
 
                int diff = Math.abs(list[a].get(0)-list[a].get(1));
 
                boolean isSame = true;
 
                for(int i=2;i<list[a].size();i++){
                   int temp =  Math.abs(list[a].get(i)-list[a].get(i-1));
                  if(diff!=temp){
                      isSame = false;
                      break;
                  }
                }
 
                if(isSame){
                    ans.add(Integer.toString(a)+" "+diff);
                }
            }
 
 
        }
 
        pn(ans.size());
 
        if(ans.size()>0){
            for (String s: ans){
                pn(s);
            }
        }    
          
            
             

            
           
    }



   	static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new AnotherReader();
        boolean oj = true;

    	//oj = System.getProperty("ONLINE_JUDGE") != null;
    	//if(!oj) sc=new AnotherReader(100);

        long s = System.currentTimeMillis();
        int t=1;//test cases
        while(t-->0)
            process();
        out.flush();
        //if(!oj)
        //    System.out.println(System.currentTimeMillis()-s+"ms");
        System.out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);System.out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    static boolean multipleTC=false;



/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class AnotherReader
    {
        BufferedReader br; StringTokenizer st;
        AnotherReader()throws FileNotFoundException
        {
              br=new BufferedReader(new InputStreamReader(System.in));
        }
        AnotherReader(int a)throws FileNotFoundException
        {
              br = new BufferedReader(new FileReader("input.txt"));
        }
        String next()throws IOException
        {
              while (st == null || !st.hasMoreElements()) 
                {
                    try
                     {
                               st = new StringTokenizer(br.readLine());
                     }
                    catch (IOException  e)
                    {
                               e.printStackTrace(); 
                     }
                }
                return st.nextToken(); 
        }
        int nextInt() throws IOException
        {
                return Integer.parseInt(next());
        }
        long nextLong() throws IOException
        {  
                return Long.parseLong(next());
        }
        double nextDouble()throws IOException 
        { 
               return Double.parseDouble(next()); 
        }
        String nextLine() throws IOException
        { 
               String str = ""; 
               try
               {
                     str = br.readLine();
               }
               catch (IOException e)
               {
                          e.printStackTrace();
               } return str;
        }
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
	
	
	