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.


/* Codeforces Template */

import static java.util.Arrays.sort;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {
    public void run() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        while (!EOF())
            solve();
        out.close();
        in.close();
    }

    void solve() throws IOException {
        int n = nextInt();
        int[] nums = nextIntArray(n);
        Map<Integer, ArrayList<Integer>> map = new HashMap<Integer, ArrayList<Integer>>();
        for (int i = 0; i < nums.length; i++) {
            if (map.containsKey(nums[i])) {
                ArrayList<Integer> value = map.get(nums[i]);
                value.add(i);
                map.put(nums[i], value);
            } else {
                ArrayList<Integer> value = new ArrayList<Integer>();
                value.add(i);
                map.put(nums[i], value);
            }
        }
        ArrayList<X> validX = new ArrayList<X>();
        for (Entry<Integer, ArrayList<Integer>> entry : map.entrySet()) {
            int key = entry.getKey();
            ArrayList<Integer> value = entry.getValue();
            if (value.size() == 1) {
                validX.add(new X(key, 0));
                continue;
            }
            int gap = value.get(1) - value.get(0);
            boolean isValid = true;
            for (int i = 1; i < value.size(); i++) {
                if (gap != value.get(i) - value.get(i - 1)) {
                    isValid = false;
                    break;
                }
            }
            if (isValid)
                validX.add(new X(key, gap));
        }
        Collections.sort(validX, new Xcomparator());
        System.out.println(validX.size());
        for (X entry : validX)
            System.out.println(entry.val + " " + entry.gap);
    }

    static long initTime;
    static final Random rnd = new Random(7777L);
    static boolean writeLog = false;

    public static void main(String[] args) throws IOException {
        initTime = System.currentTimeMillis();
        try {
            writeLog = "true".equals(System.getProperty("LOCAL_RUN_7777"));
        } catch (SecurityException e) {
        }
        new Thread(null, new Runnable() {
            public void run() {
                try {
                    try {
                        if (new File("input.txt").exists())
                            System.setIn(new FileInputStream("input.txt"));
                    } catch (SecurityException e) {
                    }
                    long prevTime = System.currentTimeMillis();
                    new Main().run();
                    log("Total time: "
                            + (System.currentTimeMillis() - prevTime) + " ms");
                    log("Memory status: " + memoryStatus());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }, "1", 1L << 24).start();
    }

    /***************************************************************
     * Input
     **************************************************************/
    BufferedReader in;
    PrintWriter out;
    StringTokenizer st = new StringTokenizer("");

    String nextToken() throws IOException {
        while (!st.hasMoreTokens())
            st = new StringTokenizer(in.readLine());
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    int[] nextIntArray(int size) throws IOException {
        int[] ret = new int[size];
        for (int i = 0; i < size; i++)
            ret[i] = nextInt();
        return ret;
    }

    long[] nextLongArray(int size) throws IOException {
        long[] ret = new long[size];
        for (int i = 0; i < size; i++)
            ret[i] = nextLong();
        return ret;
    }

    double[] nextDoubleArray(int size) throws IOException {
        double[] ret = new double[size];
        for (int i = 0; i < size; i++)
            ret[i] = nextDouble();
        return ret;
    }

    String nextLine() throws IOException {
        st = new StringTokenizer("");
        return in.readLine();
    }

    boolean EOF() throws IOException {
        while (!st.hasMoreTokens()) {
            String s = in.readLine();
            if (s == null)
                return true;
            st = new StringTokenizer(s);
        }
        return false;
    }

    /***************************************************************
     * Output
     **************************************************************/
    void printRepeat(String s, int count) {
        for (int i = 0; i < count; i++)
            out.print(s);
    }

    void printArray(int[] array) {
        if (array == null || array.length == 0)
            return;
        for (int i = 0; i < array.length; i++) {
            if (i > 0)
                out.print(' ');
            out.print(array[i]);
        }
        out.println();
    }

    void printArray(long[] array) {
        if (array == null || array.length == 0)
            return;
        for (int i = 0; i < array.length; i++) {
            if (i > 0)
                out.print(' ');
            out.print(array[i]);
        }
        out.println();
    }

    void printArray(double[] array) {
        if (array == null || array.length == 0)
            return;
        for (int i = 0; i < array.length; i++) {
            if (i > 0)
                out.print(' ');
            out.print(array[i]);
        }
        out.println();
    }

    void printArray(double[] array, String spec) {
        if (array == null || array.length == 0)
            return;
        for (int i = 0; i < array.length; i++) {
            if (i > 0)
                out.print(' ');
            out.printf(Locale.US, spec, array[i]);
        }
        out.println();
    }

    void printArray(Object[] array) {
        if (array == null || array.length == 0)
            return;
        boolean blank = false;
        for (Object x : array) {
            if (blank)
                out.print(' ');
            else
                blank = true;
            out.print(x);
        }
        out.println();
    }

    @SuppressWarnings("rawtypes")
    void printCollection(Collection collection) {
        if (collection == null || collection.isEmpty())
            return;
        boolean blank = false;
        for (Object x : collection) {
            if (blank)
                out.print(' ');
            else
                blank = true;
            out.print(x);
        }
        out.println();
    }

    /***************************************************************
     * Utility
     **************************************************************/
    static String memoryStatus() {
        return (Runtime.getRuntime().totalMemory()
                - Runtime.getRuntime().freeMemory() >> 20)
                + "/" + (Runtime.getRuntime().totalMemory() >> 20) + " MB";
    }

    static void checkMemory() {
        System.err.println(memoryStatus());
    }

    static long prevTimeStamp = Long.MIN_VALUE;

    static void updateTimer() {
        prevTimeStamp = System.currentTimeMillis();
    }

    static long elapsedTime() {
        return (System.currentTimeMillis() - prevTimeStamp);
    }

    static void checkTimer() {
        System.err.println(elapsedTime() + " ms");
    }

    static void chk(boolean f) {
        if (!f)
            throw new RuntimeException("Assert failed");
    }

    static void chk(boolean f, String format, Object... args) {
        if (!f)
            throw new RuntimeException(String.format(format, args));
    }

    static void log(String format, Object... args) {
        if (writeLog)
            System.err.println(String.format(Locale.US, format, args));
    }

    static void swap(int[] a, int i, int j) {
        int tmp = a[i];
        a[i] = a[j];
        a[j] = tmp;
    }

    static void swap(long[] a, int i, int j) {
        long tmp = a[i];
        a[i] = a[j];
        a[j] = tmp;
    }

    static void swap(double[] a, int i, int j) {
        double tmp = a[i];
        a[i] = a[j];
        a[j] = tmp;
    }

    static void shuffle(int[] a, int from, int to) {
        for (int i = from; i < to; i++)
            swap(a, i, rnd.nextInt(a.length));
    }

    static void shuffle(long[] a, int from, int to) {
        for (int i = from; i < to; i++)
            swap(a, i, rnd.nextInt(a.length));
    }

    static void shuffle(double[] a, int from, int to) {
        for (int i = from; i < to; i++)
            swap(a, i, rnd.nextInt(a.length));
    }

    static void shuffle(int[] a) {
        if (a == null)
            return;
        shuffle(a, 0, a.length);
    }

    static void shuffle(long[] a) {
        if (a == null)
            return;
        shuffle(a, 0, a.length);
    }

    static void shuffle(double[] a) {
        if (a == null)
            return;
        shuffle(a, 0, a.length);
    }

    static long[] getPartialSums(int[] a) {
        final long[] sums = new long[a.length + 1];
        for (int i = 0; i < a.length; i++)
            sums[i + 1] = sums[i] + a[i];
        return sums;
    }

    static long[] getPartialSums(long[] a) {
        final long[] sums = new long[a.length + 1];
        for (int i = 0; i < a.length; i++)
            sums[i + 1] = sums[i] + a[i];
        return sums;
    }

    static int[] getOrderedSet(int[] a) {
        final int[] set = Arrays.copyOf(a, a.length);
        if (a.length == 0)
            return set;
        shuffle(set);
        sort(set);
        int k = 1;
        int prev = set[0];
        for (int i = 1; i < a.length; i++) {
            if (prev != set[i]) {
                set[k++] = prev = set[i];
            }
        }
        return Arrays.copyOf(set, k);
    }

    static long[] getOrderedSet(long[] a) {
        final long[] set = Arrays.copyOf(a, a.length);
        if (a.length == 0)
            return set;
        shuffle(set);
        sort(set);
        int k = 1;
        long prev = set[0];
        for (int i = 1; i < a.length; i++) {
            if (prev != set[i]) {
                set[k++] = prev = set[i];
            }
        }
        return Arrays.copyOf(set, k);
    }
}

class X {
    int val;
    int gap;

    public X(int _val, int _gap) {
        val = _val;
        gap = _gap;
    }
}

class Xcomparator implements Comparator<X> {

    @Override
    public int compare(X o1, X o2) {
        // TODO Auto-generated method stub
        return o1.val - o2.val;
    }

}