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.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.Flushable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {
	static Reader in = new Reader(System.in);
	static Writer out = new Writer(System.out);

	/*
	8
	1 2 1 3 1 2 1 5
	*/

	static class Track {
		int diff;
		int lastIndex;

		public Track(int diff, int lastIndex) {
			this.diff = diff;
			this.lastIndex = lastIndex;
		}
	}

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

		// read input
		int n = in.nextInt();
		int[] a = in.nextIntArray(n);

		Set<Integer> fail = new HashSet<>();
		SortedMap<Integer, Track> data = new TreeMap<>();
		for (int i = 0; i < a.length; i++) {
			int x = a[i];
			if (fail.contains(x)) {
				// ignore
				continue;
			}

			if (!data.containsKey(x)) {
				data.put(x, new Track(0, i));
			} else {
				Track t = data.get(x);
				int d = i - t.lastIndex;
				t.lastIndex = i;
				if (t.diff == 0) {
					t.diff = d;
				} else if (t.diff != d){
					fail.add(x);
					data.remove(x);
				}
			}
		}
		// print output
		out.println(data.size());
		for (Map.Entry<Integer, Track> entry : data.entrySet()) {
			out.println(entry.getKey() + " " + entry.getValue().diff);
		}

		// close stuff
		in.close();
		out.flush();
		out.close();
	}

	private static boolean isOddNumberOfToggles(int n) {
		int res = 1; // last walk always toggle
		for (int i = 1; i < Math.sqrt(n) +1; i++) {
			if (n%i == 0) res++;
		}
		return res % 2 != 0;
	}

	static class Reader implements Closeable {

		private final BufferedReader reader;
		private StringTokenizer tokenizer;

		public Reader(InputStream input) {
			reader = new BufferedReader(
					new InputStreamReader(input));
			tokenizer = new StringTokenizer("");
		}

		private StringTokenizer getTokenizer() throws IOException {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				String line = nextLine();
				if (line == null) {
					return null;
				}
				tokenizer = new StringTokenizer(line);
			}
			return tokenizer;
		}

		public boolean hasNext() throws IOException {
			return getTokenizer() != null;
		}

		public String next() throws IOException {
			return hasNext() ? tokenizer.nextToken() : null;
		}

		public String nextLine() throws IOException {
			tokenizer = null;
			return reader.readLine();
		}

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

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

		public float nextFloat() throws IOException {
			return Float.parseFloat(next());
		}

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

		public String[] nextStringArray(int size) throws IOException {
			String[] array = new String[size];
			for (int i = 0; i < size; i++) {
				array[i] = next();
			}
			return array;
		}

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

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

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

		@Override
		public void close() throws IOException {
			tokenizer = null;
			reader.close();
		}
	}

	static class Writer implements Closeable, Flushable {

		private final PrintWriter writer;

		public Writer(OutputStream outputStream) {
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
		}

		public void print(Object... objects) {
			for (int i = 0; i < objects.length; i++) {
				if (i != 0) {
					writer.print(' ');
				}
				writer.print(objects[i]);
			}
		}

		public void println(Object... objects) {
			print(objects);
			writer.println();
		}

		@Override
		public void close() {
			writer.close();
		}

		@Override
		public void flush() {
			writer.flush();
		}
	}


}
