#include <iostream>
using namespace std;

int main () {
int nech, ch, br, maxch2, maxnech2;
cin >> br;
for (int i=1; i<=br; i++) {
    cin >> ch;
    cin.get ();
    int p = ch%2;
    if (p==0) {
        ch = ch;
    } else {
        ch = nech;
    }
    int maxch = ch;
    if (ch>maxch) {
        maxch = ch;
    }
    maxch2 = maxch+2;
    int maxnech = nech;
    if (nech>maxch) {
        maxnech = nech;
    }
    int maxnech2 = maxnech+2;
}
cout << maxch2 << " " << maxnech2 << endl;



return 0;
}
