#include <bits/stdc++.h>
const double PI = acos(-1);
using namespace std;
const int mod = 1e5 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(NULL);
  cin.tie(NULL);
  ;
  long long n;
  cin >> n;
  vector<long long> v(mod), v1(mod);
  map<long long, long long> m, mp;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    mp[x]++;
    if (v[x] == 0)
      v[x] = i + 1;
    else {
      if (mp[x] == 2) {
        v[x] = i + 1 - v[x];
        v1[x] = i + 1;
      } else {
        if (m[x] != -1 && i + 1 - v1[x] == v[x]) {
          m[x] = v[x];
          v1[x] = i + 1;
        } else
          m[x] = -1;
      }
    }
  }
  auto it = mp.end();
  it--;
  for (int i = 1; i <= it->first; i++)
    if (v[i] > 0 && mp[i] <= 2) {
      if (mp[i] == 1)
        m[i] = 0;
      else
        m[i] = v[i];
    }
  long long z = 0;
  for (auto m : m)
    if (m.second > -1) z++;
  cout << z << "\n";
  for (auto m : m)
    if (m.second > -1) cout << m.first << " " << m.second << "\n";
  return 0;
}
