#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

struct store
{
	store(long long a)
	{
		num = a;
	}
	long long num;
	long long count = 1;
};

bool compare(store a, store b)
{
	return (a.num < b.num);
}

int main()
{
	ifstream input("tansuat.inp");
	ofstream output("tansuat.out");
	long long n;
	long long a;
	bool exist = false;
	bool con = false;
	input >> n;
	vector <store> b;
	for (int i = 0; i < n; i++)
	{
		con = false;
		input >> a;
		for (int i = 0; i < b.size(); i++)
		{
			if (a == b[i].num)
			{
				b[i].count++;
				con = true;
				continue;
			}
		}
		if (con == false)
		{
			b.push_back(store(a));
		}
	}
	sort(b.begin(), b.end(), compare);
	for (int i = 0; i < b.size(); i++)
	{
		if (b[i].count != 1)
		{
			output << b[i].num << ' ' << b[i].count << '\n';
			exist = true;
		}
	}
	if (exist == false)
	{
		output << 0;
	}
	input.close();
	output.close();
	return 0;
}