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.*;
import java.util.*;

/**
 * @author pvasilyev
 * @since 04 Oct 2013
 */
public class ProblemB {

    public static final String FILE_IN = "std.in";
    public static final String FILE_OUT = "std.out";
    private static boolean debugMode = true;

    public static void main(String[] args) throws IOException {

        final InputReader reader = new InputReader((debugMode ? System.in : new FileInputStream(FILE_IN)));
        final PrintWriter writer = new PrintWriter(debugMode ? System.out : new FileOutputStream(FILE_OUT));

        solveTheProblem(reader, writer);

        writer.close();
    }

    private static void solveTheProblem(final InputReader reader, final PrintWriter writer) {
        final int n = reader.readInt();

        final int[] ints = IOUtils.readIntArray(reader, n);
        final HashMap<Integer, ArrayList<Integer>> map = new HashMap<>();

        for (int k = 0; k < n; ++k) {
            if (!map.containsKey(ints[k])) {
                map.put(ints[k], new ArrayList<Integer>());
            }
            map.get(ints[k]).add(k);
        }

        final ArrayList<Pair> result = new ArrayList<>();

        for (Map.Entry<Integer, ArrayList<Integer>> integerSortedSetEntry : map.entrySet()) {
            final Integer key = integerSortedSetEntry.getKey();
            final ArrayList<Integer> positions = integerSortedSetEntry.getValue();

            if (positions.size() == 1) {
                result.add(new Pair(key, 0));
            } else if (acceptsArithmeticConstraint(positions)) {
                result.add(new Pair(key, calculateDiff(positions)));
            }
        }

        Collections.sort(result, new Comparator<Pair>() {
            @Override
            public int compare(final Pair o1, final Pair o2) {
                return Integer.compare(o1.value, o2.value);
            }
        });

        writer.println(result.size());
        for (Pair pair : result) {
            writer.println(pair.value + " " + pair.p);
        }
    }

    private static boolean acceptsArithmeticConstraint(final ArrayList<Integer> positions) {
        final Iterator<Integer> iterator = positions.iterator();
        iterator.next();
        Integer current = iterator.next();
        Integer next;
        final int diff = calculateDiff(positions);

        while (iterator.hasNext()) {
            next = iterator.next();
            if (next - current != diff) {
                return false;
            }
            current = next;
        }

        return true;
    }

    private static int calculateDiff(final ArrayList<Integer> positions) {
        final Iterator<Integer> iterator = positions.iterator();
        final Integer first = iterator.next();
        final Integer second = iterator.next();
        return second - first;
    }

    private static final class Pair {
        int value;
        int p;

        private Pair(final int value, final int p) {
            this.value = value;
            this.p = p;
        }
    }

}




class InputReader {

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int readInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return isWhitespace(c);
    }

    public static boolean isWhitespace(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
}

class IOUtils {

    public static int[] readIntArray(InputReader in, int size) {
        int[] array = new int[size];
        for (int i = 0; i < size; i++)
            array[i] = in.readInt();
        return array;
    }

}
