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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.IntStream;
import java.util.stream.LongStream;

public class Solution {
//    ----------------------------------------------------------------------------

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {

            int n = in.nextInt();
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {

                a[i] = in.nextInt();
            }
            boolean found[] = new boolean[100001];
            int commonDiff[] = new int[100001];
            int count[] = new int[100001];
            int lastApp[] = new int[100001];
            boolean fail[] = new boolean[100001];

            for (int i = 0; i < n; i++) {

                int x = a[i];
                if (found[x] && !fail[x]) {

                    if (count[x] == 1) {
                        //  System.out.println(a[i] + " has been found agaiin . so common diff = " + (i - lastApp[a[i]]));
                        count[x]++;
                        commonDiff[x] = i - lastApp[x];
                        lastApp[x] = i;

                    } else {
                        //System.out.println("i = " + i + " and last time i = " + lastApp[a[i]]);
                        int cd = i - lastApp[x];

                        //System.out.println(a[i] + " has been found for the " + (count[a[i]] + 1) + " time and cd == " + cd);
                        if (cd == commonDiff[x]) {

                            count[x]++;
                            lastApp[x] = i;

                        } else {
                            fail[x] = true;

                        }

                    }

                } else if (!found[a[i]]) {

                    //System.out.println("a[i] = " + a[i] + " has been found");
                    count[x]++;
                    lastApp[x] = i;
                    found[x] = true;

                }
            }

            int num = 0;

            for (int i = 0; i < 100001; i++) {

                if (!fail[i] && found[i]) {

                    num++;

                }

            }

            out.println(num);

            for (int i = 1; i < 100001; i++) {

                if (!fail[i] && found[i]) {

                    out.println(i + " " + commonDiff[i]);

                }

            }

        }

    }

//    ----------------------------------------------------------------------------
    // IMPORTANT || COMMON  METHODS
    // PAIR
    static class Pair {

        int x;
        int y;

        // Constructor 
        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        // how to initialize
//            Pair level[] = new Pair[n];
//            for (int i = 0; i < n; i++) {
//                int x = in.nextInt();
//                int y = in.nextInt();
//
//                level[i] = new Pair(x, y);
//
//            }
        // How to sort
//              PairSort ps = new PairSort();
//              ps.sort(level, 1);
    }

    static class PairSort {

        Pair[] sort(Pair arr[], int i) {
            // Comparator to sort the pair according to second element 
            Arrays.sort(arr, new Comparator<Pair>() {
                @Override
                public int compare(Pair p1, Pair p2) {

                    if (i == 2) {
                        return p1.y - p2.y;
                    } else if (i == 1) {
                        return p1.x - p2.x;

                    } else if (i == 4) {
                        return p2.y - p1.y;

                    } else {

                        return p2.x - p1.x;
                    }

                }
            });

            return arr;
        }
    }

    // GCD || HCF
    static long GCD(long x, long y) {
        return y == 0 ? x : GCD(y, x % y);
    }

    // LCM 
    static long LCM(long a, long b) {
        return (a * b) / GCD(a, b);
    }

    // Returns the divisors of a number
    static ArrayList Divisors(long n) {
        ArrayList<Long> div = new ArrayList<>();

        for (long i = 1; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                div.add(i);

                if (n / i != i) {
                    div.add(n / i);
                }
            }
        }
        return div;
    }

//    ----------------------------------------------------------------------------
    // MAIN - INPUT - OUTPUT 
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public Double nextDouble() {
            return Double.parseDouble(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int[] nextIntArray(int arraySize) {
            int array[] = new int[arraySize];

            for (int i = 0; i < arraySize; i++) {
                array[i] = nextInt();
            }

            return array;
        }

    }
}
