#include <iostream>
using namespace std;
//Functie care verifica daca numarul nr e prim
bool este_prim(int nr)
{
if (nr < 2)
return false;
if (nr == 2)
return true;
for (int index = 2; index * index <= nr; index++)
if (nr % index == 0)
return false;
return true;
}
int main()
{
unsigned n, index, v[1001];
//Primeste vector
cin >> n;
for (index = 1; index <= n; index++)
cin >> v[index];
//Parcurge elementele
for (index = 1; index < n; index++)
//Daca suma a doua elemente consecutive e numar prim afiseaza elementele
if (este_prim(v[index] + v[index + 1]))
cout << v[index] << " " << v[index + 1] << endl;
return 0;
}