public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] num = new int[n];
        Map<Integer, Integer> prevIndexMap = new HashMap<Integer, Integer>();
        SortedMap<Integer, Integer> diffMap = new TreeMap<Integer, Integer>();
        Set<Integer> ditched = new HashSet<Integer>();
        for (int i = 0; i < n; i++) {
            num[i] = in.nextInt();
            if (ditched.contains(num[i])) {
                continue;
            }
            if (prevIndexMap.containsKey(num[i])) {
                int prevIndex = prevIndexMap.get(num[i]);
                int diff = i - prevIndex;
                int prevDiff = diffMap.get(num[i]);
                if (prevDiff != 0 && prevDiff != diff) {
                    diffMap.remove(num[i]);
                    ditched.add(num[i]);
                } else if (prevDiff == 0) {
                    diffMap.put(num[i], diff);
                    prevIndexMap.put(num[i], i);
                } else {
                    prevIndexMap.put(num[i], i);
                }
            } else {
                prevIndexMap.put(num[i], i);
                diffMap.put(num[i], 0);
            }
        }
        System.out.println(diffMap.size());
        for (int key : diffMap.keySet()) {
            System.out.println(key + " " + diffMap.get(key));
        }
    }