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

public class JeffandPeriods {
    BufferedReader input;
    BufferedWriter output;
    StringTokenizer st;
    
    
    // My Solution
    void solve() throws IOException {
        int n = getInt();
        int[] a = getInts(n);
        HashMap<Integer, Queue<Integer>> map = new HashMap<>();
        for(int i=0; i<n; i++){
            int e = a[i];
            Queue<Integer> queue;
            if(map.containsKey(e)){
                queue = map.get(e);
            }else {
                queue = new LinkedList<>();
                map.put(e, queue);
            }
            queue.add(i);
        }
        int count = 0;
        StringBuilder stringBuilder = new StringBuilder();
        ArrayList<Integer> values = new ArrayList<>(map.keySet());
        Collections.sort(values);
        for(int key : values){
            Queue<Integer> queue = map.get(key);
            if(queue.size()>1){
                boolean holds = true;
                int first = queue.poll();
                int last = queue.poll();
                int commonDifference = last-first;
                while (!queue.isEmpty()){
                    int index = queue.poll();
                    if(index-last!=commonDifference){
                        holds = false;
                        break;
                    }
                    last = index;
                }
                if(holds){
                    count++;
                    stringBuilder.append(key).append(" ").append(commonDifference).append("\n");
                }
            }else {
                count++;
                stringBuilder.append(key).append(" 0\n");
            }
        }
        output.write(count+"\n");
        output.write(stringBuilder.toString());
    }
    
    
    // Some basic functions
    int min(int...i){
        int min = Integer.MAX_VALUE;
        for (int value : i) min = Math.min(min, value);
        return min;
    }
    int max(int...i){
        int max = Integer.MIN_VALUE;
        for (int value : i) max = Math.max(max, value);
        return max;
    }
    // Printing stuff
    void print(int... i) throws IOException {
        for (int value : i) output.write(value + " ");
    }
    void print(long... l) throws IOException {
        for (long value : l) output.write(value + " ");
    }
    void print(String... s) throws IOException {
        for (String value : s) output.write(value);
    }
    void nextLine() throws IOException {
        output.write("\n");
    }
    // Taking Inputs
    int[][] getIntMat(int n, int m) throws IOException {
        int[][] mat = new int[n][m];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                mat[i][j] = getInt();
        return mat;
    }
    char[][] getCharMat(int n, int m) throws IOException {
        char[][] mat = new char[n][m];
        for (int i = 0; i < n; i++) {
            String s = input.readLine();
            for (int j = 0; j < m; j++) 
                mat[i][j] = s.charAt(j);
        }
        return mat;
    }
    int getInt() throws IOException {
        if(st ==null || !st.hasMoreTokens())
            st = new StringTokenizer(input.readLine());
        return Integer.parseInt(st.nextToken());
    }
    int[] getInts(int n) throws IOException {
        int[] a = new int[n];
        StringTokenizer st = new StringTokenizer(input.readLine());
        for (int i = 0; i < n; i++)
            a[i] = Integer.parseInt(st.nextToken());
        return a;
    }
    long getLong() throws IOException {
        if(st==null || !st.hasMoreTokens())
            st = new StringTokenizer(input.readLine());
        return Long.parseLong(st.nextToken());
    }
    long[] getLongs(int n) throws IOException {
        long[] a = new long[n];
        StringTokenizer st = new StringTokenizer(input.readLine());
        for (int i = 0; i < n; i++)
            a[i] = Long.parseLong(st.nextToken());
        return a;
    }
    // Checks whether the code is running on OnlineJudge or LocalSystem
    boolean isOnlineJudge() {
        if (System.getProperty("ONLINE_JUDGE") != null)
            return true;
        try {
            return System.getProperty("LOCAL")==null;
        } catch (Exception e) {
            return true;
        }
    }
    // Handling CodeExecution
    public static void main(String[] args) throws Exception {
        new JeffandPeriods().run();
    }
    void run() throws IOException {
        // Defining Input Streams
        if (isOnlineJudge()) {
            input = new BufferedReader(new InputStreamReader(System.in));
            output = new BufferedWriter(new OutputStreamWriter(System.out));
        } else {
            input = new BufferedReader(new FileReader("input.txt"));
            output = new BufferedWriter(new FileWriter("output.txt"));
        }
        // Running Logic
        solve();
        output.flush();
        // Run example test cases
        if (!isOnlineJudge()) {
            BufferedReader output = new BufferedReader(new FileReader("output.txt"));
            BufferedReader answer = new BufferedReader(new FileReader("answer.txt"));
            StringBuilder outFile = new StringBuilder();
            StringBuilder ansFile = new StringBuilder();
            String temp;
            while ((temp = output.readLine()) != null)
                outFile.append(temp.trim());
            while ((temp = answer.readLine()) != null)
                ansFile.append(temp.trim());
            if (outFile.toString().equals(ansFile.toString()))
                System.out.println("Test Cases Passed!!!");
            else
                System.out.println("Failed...");
        }
    }
}