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 solution;

import java.io.*;
import java.util.*;
import java.awt.Point;
import java.math.BigInteger;

public final class Main {
    BufferedReader br;
    StringTokenizer stk;

    public static void main(String[] args) throws Exception {
        new Main().run();
    }
    
    {
        stk = null;
        br = new BufferedReader(new InputStreamReader(System.in));
    }
    
    void run() throws Exception {
        int n = ni();
        HashMap<Integer, List<Integer>> map = new HashMap<>();
        for(int i=0; i<n; i++) {
            int num = ni();
            if(!map.containsKey(num))
                map.put(num, new ArrayList<>());
            map.get(num).add(i);
        }
        
        List<Point> list = new ArrayList<>();
        for(int key : map.keySet()) {
            if(isAP(map.get(key))) {
                int x = key;
                int d = getDiff(map.get(x));
                list.add(new Point(x, d));
            }
        }
        
        Collections.sort(list, new Comparator<Point>() {
            @Override
            public int compare(Point p, Point q) {
                return p.x - q.x;
            }
        });
        
        StringBuilder res = new StringBuilder(100000 << 3);
        res.append(list.size()).append("\n");
        for(int i=0; i<list.size(); i++) {
            res.append(list.get(i).x).append(" ").append(list.get(i).y).append("\n");
        }
        
        p(res);
    }
    
    int getDiff(List<Integer> list) {
        if(list.size() == 1) return 0;
        return list.get(1) - list.get(0);
    }
    
    boolean isAP(List<Integer> list) {
        if(list.size() == 1) return true;
        int diff = list.get(1) - list.get(0);
        for(int i=1; i<list.size(); i++) {
            if(list.get(i) - list.get(i-1) != diff)
                return false;
        }
        return true;
    }
    
    //Reader & Writer
    String nextToken() throws Exception {
        if (stk == null || !stk.hasMoreTokens()) {
            stk = new StringTokenizer(br.readLine(), " ");
        }
        return stk.nextToken();
    }

    String nt() throws Exception {
        return nextToken();
    }

    String ns() throws Exception {
        return br.readLine();
    }

    int ni() throws Exception {
        return Integer.parseInt(nextToken());
    }

    long nl() throws Exception {
        return Long.parseLong(nextToken());
    }

    double nd() throws Exception {
        return Double.parseDouble(nextToken());
    }

    void p(Object o) {
        System.out.print(o);
    }

    void pl(Object o) {
        System.out.println(o);
    }
}