#include <bits/stdc++.h>
using namespace std;
int main() {
  map<int, int> p, q, r;
  int n;
  int flag = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int temp;
    cin >> temp;
    q[temp]++;
    if (q[temp] == INT_MAX) continue;
    if (q[temp] == 1) {
      p[temp] = i;
      r[temp] = 0;
    } else if (q[temp] == 2) {
      r[temp] = i - p[temp];
      p[temp] = i;
    } else if (q[temp] > 2) {
      if (i - p[temp] == r[temp]) {
        p[temp] = i;
      } else {
        q[temp] = INT_MAX;
        r.erase(temp);
      }
    }
  }
  map<int, int>::iterator itr;
  cout << r.size() << endl;
  for (itr = r.begin(); itr != r.end(); ++itr) {
    if (itr->second != INT_MAX)
      cout << itr->first << " " << itr->second << endl;
  }
  return 0;
}
