#include <fstream>
#include <iostream>
#include <algorithm>
int a[100000000];
using namespace std;
int main()
{
    ifstream fi("tansuat.inp");
    ofstream fo("tansuat.out");
    int n,d = 1;
    bool kt = false;
    fi >> n;
    for (int i = 0; i < n; i++) fi >> a[i];
    sort(a,a+n);
    a[n] = -1;
    for (int i = 1; i < n+1; i++)
    {
       if (a[i] == a[i-1]) d++;
       else
       {
           if (d > 1) {fo << a[i-1] << " " << d << endl; kt = true;}
           d = 1;
       }
    }
    if (kt == false) fo << 0;
    return 0;
}
