#include <bits/stdc++.h>
using namespace std;
using llong = long long int;
const static int MOD = 1000000007;
const static int INF = 1000000000;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};
template <typename T>
T my_gcd(T a, T b) {
  return (a ? my_gcd(b % a, a) : b);
}
map<llong, llong> M;
template <typename T>
void factorization(T p) {
  llong i = 2;
  while (i * i <= p) {
    if (p % i == 0) {
      ++M[i];
      p /= i;
    } else {
      ++i;
    }
  }
  if (p != 1) ++M[p];
  return;
}
int main(int argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<llong> A(n);
  for (int i = 0; i < n; ++i) cin >> A[i];
  for (int i = 0; i < n; ++i) factorization(A[i]);
  for (auto itr = M.begin(); itr != M.end(); ++itr) {
    cout << itr->first << ' ' << itr->second << endl;
  }
  return 0;
}
