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.
//package codeforces;

import java.io.*;
import java.util.*;

public class B {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter writer = new PrintWriter(System.out);
    StringTokenizer stringTokenizer;

    B() throws IOException {
//        reader = new BufferedReader(new FileReader("cycle2.in"));
//        writer = new PrintWriter(new FileWriter("cycle2.out"));
    }

    String next() throws IOException {
        while (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
            stringTokenizer = new StringTokenizer(reader.readLine());
        }
        return stringTokenizer.nextToken();
    }

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

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

    int[][] mul(int[][] a, int[][] b) {
        int[][] result = new int[2][2];
        for(int i = 0; i < 2; i++) {
            for(int j = 0; j < 2; j++) {
                for(int k = 0; k < 2; k++) {
                    result[i][j] = sum(result[i][j], product(a[i][k], b[k][j]));
                }
            }
        }
        return result;
    }

    int[][] pow(int[][] a, int k) {
        int[][] result = {{1, 0}, {0, 1}};
        while(k > 0) {
            if(k % 2 == 1) {
                result = mul(result, a);
            }
            a = mul(a, a);
            k /= 2;
        }
        return result;
    }

    final int MOD = 1000 * 1000 * 1000 + 7;

    int sum(int a, int b) {
        a += b;
        return a >= MOD ? a - MOD : a;
    }
    int product(int a, int b) {
        return (int)(1l * a * b % MOD);
    }

    @SuppressWarnings("unchecked")
    void solve() throws IOException {
        int n = nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        Map<Integer, Integer> firstOccurrence = new HashMap<>();
        Map<Integer, Integer> ans = new TreeMap<>();
        for(int i = 0; i < n; i++) {
            if(!firstOccurrence.containsKey(a[i])) {
                firstOccurrence.put(a[i], i);
                ans.put(a[i], 0);
            } else {
                int p = ans.get(a[i]);
                if(p == -1) {
                    continue;
                }
                if(p == 0) {
                    ans.put(a[i], i - firstOccurrence.get(a[i]));
                } else {
                    if(a[i - p] != a[i]) {
                        ans.put(a[i], -1);
                    }
                }
            }
        }
        List<String> stringAns = new ArrayList<>();
        for (Map.Entry<Integer, Integer> entry : ans.entrySet()) {
            if(entry.getValue() == -1) {
                continue;
            }
            stringAns.add(String.format("%d %d", entry.getKey(), entry.getValue()));
        }
        writer.println(stringAns.size());
        for (String s : stringAns) {
            writer.println(s);
        }
        writer.close();
    }


    public static void main(String[] args) throws IOException {
        new B().solve();
    }

}