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

public class Main{
    private boolean isValid(ArrayList<Integer> al, int diff, int n){
        for (int i = 1; i < n-1; i++) if (al.get(i+1)-al.get(i) != diff) return false;
        return true;
    }
    public void solve() throws Exception{
        int n = ri();
        int[] a = ria(n);
        Map<Integer, ArrayList> map = new TreeMap<>();
        for (int i = 0; i < n; i++){
            if (map.get(a[i]) == null){
                ArrayList<Integer> al = new ArrayList<>();
                al.add(i);
                map.put(a[i], al);
            }else{
                ArrayList<Integer> al = map.get(a[i]);
                al.add(i);
                map.put(a[i], al);
            }
        }
        // print ans
        ArrayList<Integer> x = new ArrayList<>(), d = new ArrayList<>();
        int count = 0;
        for(Map.Entry<Integer,ArrayList> entry : map.entrySet()) {
            ArrayList<Integer>  al = entry.getValue();
            int len = al.size();
            if (len == 1){
                x.add(entry.getKey());
                d.add(0); count++;
            }else{
                int diff = al.get(1)-al.get(0);
                if (isValid(al, diff, len)){ x.add(entry.getKey()); d.add(diff); count++; }
            }
        }
        println(""+count);
        for (int i = 0; i < count; i++) println(x.get(i)+" "+d.get(i));
        out.close();
    }

    public static void main(String[] args) throws Exception{
        Main m = new Main();
        m.solve();
    }

    /* Template Methods */
    private BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    private BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
    //private PrintWriter out = new PrintWriter(System.out, true);
    private StringTokenizer st;
    /* console write methods */
    private void print(String s) throws  Exception{
        out.write(s);
    }
    private void println(String s) throws Exception{
        out.write(s);
        out.newLine();
    }

    /* console read methods */
    private String rs() throws IOException{
        return in.readLine();
    }
    private int ri() throws IOException{
        return Integer.parseInt(rs());
    }
    private float rf() throws  IOException{
        return Float.parseFloat(rs());
    }
    private double rd() throws IOException{
        return Double.parseDouble(rs());
    }
    private int[] ria(int size) throws IOException{
        int[] a = new int[size];
        st = new StringTokenizer(rs(), " ");
        int i = 0;
        while(st.hasMoreTokens()){ a[i] = Integer.parseInt(st.nextToken()); i++; }
        return a;
    }
    private long[] rla(int size) throws IOException{
        long[] a = new long[size];
        st = new StringTokenizer(rs(), " ");
        int i = 0;
        while(st.hasMoreTokens()){ a[i] = Long.parseLong(st.nextToken()); i++; }
        return a;
    }
    private ArrayList ral() throws IOException{
        ArrayList al = new ArrayList();
        st = new StringTokenizer(rs(), " ");
        while(st.hasMoreTokens()) al.add(st.nextToken());
        return al;
    }
    /* MAX & MIN */
    private int max(int[] a){
        int max = Integer.MIN_VALUE;
        for (int x: a) if (x > max) max = x;
        return max;
    }
    private int min(int[] a){
        int min = Integer.MAX_VALUE;
        for (int x: a) if (x < min) min = x;
        return min;
    }
}