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.
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long fact[1000001];
long long inv[1000001];
long long primes[100007];
long long arr[1000007];
long long modPower(long long b, long long p) {
  if (p == 0) return 1;
  long long halfpow = modPower(b, p / 2);
  long long toReturn = (halfpow * halfpow) % mod;
  if (p % 2) toReturn = (toReturn * b) % mod;
  return toReturn;
}
long long fastPower(long long b, long long p) {
  if (p == 0) return 1;
  long long ans = fastPower(b, p / 2);
  ans = (ans * ans);
  if (p % 2 != 0) ans = (ans * b);
  return ans;
}
long long GcdRecursive(long long a, long long b) {
  if (b == 0) return a;
  return GcdRecursive(b, a % b);
}
long long modLCM(long long a, long long b) {
  long long val = GcdRecursive(a, b);
  long long tmp = ((a % mod) * (b % mod)) % mod;
  long long finalVal = ((tmp % mod) * (arr[val] % mod)) % mod;
  return finalVal;
}
long long LCM(long long a, long long b) { return (a * b) / GcdRecursive(a, b); }
void move1step(long long& a, long long& b, long long q) {
  long long c = a - q * b;
  a = b;
  b = c;
}
long long GcdIterative(long long a, long long b) {
  while (b) move1step(a, b, a / b);
  return a;
}
void pre(long long n) {
  fact[0] = 1;
  inv[0] = 1;
  for (long long i = 1; i <= n; i++) {
    fact[i] = (i * fact[i - 1]) % mod;
    inv[i] = modPower(fact[i], mod - 2);
    arr[i] = modPower(i, mod - 2);
  }
}
long long npr(long long n, long long r) {
  return ((fact[n] * inv[n - r]) % mod);
}
long long ncr(long long n, long long r) {
  return ((((fact[n] * inv[n - r]) % mod) * inv[r]) % mod);
}
void sieve(long long val) {
  memset(primes, 1, sizeof primes);
  primes[0] = primes[1] = false;
  for (int i = 2; i <= val; i++) {
    if (primes[i]) {
      for (int j = i * i; j <= val; j += i) {
        primes[j] = 0;
      }
    }
  }
}
long double dot(complex<long double> a, complex<long double> b) {
  return (conj(a) * b).real();
}
long double cross(complex<long double> a, complex<long double> b) {
  return (conj(a) * b).imag();
}
long double angleBetVec(complex<long double> a, complex<long double> b) {
  long double d = dot(a, b);
  d /= abs(a);
  d /= abs(b);
  return acos(d) * 180 / acos(-1);
}
complex<long double> RotateAbout(complex<long double> a,
                                 complex<long double> about,
                                 long double angle) {
  return (a - about) * polar((long double)1.0, angle) + about;
}
const long long MOD = 998244353;
const long long N = 1e5 + 7;
const long long inf = 1e18 + 5;
const long long mm = 1e6 + 3;
long long n, a;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> n;
  map<long long, vector<long long> > mp;
  for (int i = 0; i < n; i++) {
    cin >> a;
    mp[a].push_back(i);
  }
  long long cnt = 0;
  for (auto e : mp) {
    if (e.second.size() == 1) {
      continue;
    }
    long long diff = e.second[1] - e.second[0];
    for (int i = 0; i < e.second.size() - 1; i++) {
      if (e.second[i + 1] - e.second[i] != diff) {
        cnt++;
        mp[e.first].clear();
        break;
      }
    }
  }
  cout << mp.size() - cnt << "\n";
  for (auto e : mp) {
    if (e.second.size() == 0) continue;
    if (e.second.size() == 1) {
      cout << e.first << ' ' << 0 << "\n";
      continue;
    }
    cout << e.first << " " << e.second[1] - e.second[0] << "\n";
  }
}
