#include <bits/stdc++.h>
using namespace std;
string v2s(vector<long long int>& A) {
  long long int Z = ((long long int)A.size());
  string second(Z, ' ');
  for (long long i = 0; i < Z; i++) second[i] = A[i] + '0';
  return second;
}
const int MOD = 1e9 + 7;
const int MAX = 2e5 + 5;
const long long int INF = 1e18;
const double PI = acos(-1.0);
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
vector<pair<long long int, long long int>> A;
bool cmp(pair<long long int, long long int>& a,
         pair<long long int, long long int>& b) {
  return a.second < b.second;
}
void sort(map<long long int, long long int>& M) {
  for (auto& it : M) {
    A.push_back(it);
  }
  sort(A.begin(), A.end(), cmp);
}
bool comp(pair<double, long long int> a, pair<double, long long int> b) {
  return (a.first == b.first ? a.second < b.second : a.first > b.first);
}
long long int powMod(long long int x, long long int y) {
  long long int res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x) % MOD;
    x = (x * x) % MOD;
    y >>= 1;
  }
  return res;
}
long long int stringdigitsum(string digits) {
  long long int num, total = 0;
  for (int i = 0; i < digits.length(); i++) {
    num = digits.at(i) - '0';
    assert(0 <= num && num <= 9);
    total += num;
  }
  return total;
}
long long int vis[2005];
long long int ar[1005];
vector<long long int> vr[2005];
long long int bfs(long long int n) {
  long long int ans = 0;
  vis[n] = 1;
  queue<long long int> q;
  q.push(n);
  while (!q.empty()) {
    long long int f = q.front();
    q.pop();
    long long int res = ar[f];
    for (auto it : vr[f]) {
      if (!vis[it]) {
        q.push(it);
        res += res ^ ar[it];
        vis[it] = 1;
      }
    }
    ans += res;
  }
  return ans;
}
int main() {
  long long int a, b, i, c, d, e, g, r, j,
      k = 0, l, f = 0, h = 0, tttt = 0, o = 0, q, t, x, p, u, w, n, m = 0, z, y,
      cnt;
  string s, s2;
  char cc, cc1;
  cin >> n;
  set<long long int> beda;
  vector<vector<long long int>> adj(100005);
  vector<pair<long long int, long long int>> ans;
  for (long long int i = 1; i <= n; i++) {
    cin >> x;
    adj[x].push_back(i);
    beda.insert(x);
  }
  for (auto i : beda) {
    set<long long int> temp;
    long long int temp2 = 0;
    for (long long int j = 0; j < adj[i].size() - 1; j++) {
      temp2 = abs(adj[i][j] - adj[i][j + 1]);
      temp.insert(temp2);
    }
    if (temp.size() <= 1) ans.push_back({i, temp2});
  }
  cout << ans.size() << '\n';
  for (long long int i = 0; i < ans.size(); i++)
    cout << ans[i].first << " " << ans[i].second << '\n';
  return 0;
}
