#include <bits/stdc++.h>
using namespace std;
const long long OO = (long long)1e18 + 9;
const int oo = 2147483647;
const double EPS = 1e-9;
const double PI = acos(-1.0);
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
int dX[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dY[] = {0, 1, 0, -1, 1, 1, -1, -1};
char letters[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                  'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                  's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
int dot(int x, int y, int x2, int y2) { return x * x2 + y * y2; }
long long gcd(long long x, long long y) { return !y ? x : gcd(y, x % y); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
int ord(int r, int c, int nCol) { return (nCol * r) + c + 1; }
int cmpDouble(long double d1, long double d2) {
  return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1;
}
int main() {
  int n;
  cin >> n;
  vector<int> v(n), vis(100010, -1), mp(100010, 0);
  set<pair<int, int> > ans;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    if (!mp[v[i]])
      mp[v[i]] = i + 1, vis[v[i]] = 0;
    else if (!vis[v[i]])
      vis[v[i]] = i + 1 - mp[v[i]], mp[v[i]] = i + 1;
    else if (i + 1 - mp[v[i]] == vis[v[i]])
      mp[v[i]] = i + 1;
    else
      vis[v[i]] = oo;
  }
  for (int i = 0; i < 100010; i++)
    if (vis[i] != -1 && vis[i] != oo) ans.insert(make_pair(i, vis[i]));
  cout << (int)ans.size() << endl;
  for (auto it : ans) cout << it.first << ' ' << it.second << endl;
  return 0;
}
