#include <iostream>
using namespace std;
int main(void)
{
int n, max, min, a;
cin >> n;
for(int i = 0; i < n; i++)
{
cin >> a;
if(i == 0)
max = a, min = a;
if(max < a)
max = a;
if(min > a)
min = a;
}
cout << min << " " << max;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKHZvaWQpCnsKICAgIGludCBuLCBtYXgsIG1pbiwgYTsKICAgIGNpbiA+PiBuOwogICAgCiAgICBmb3IoaW50IGkgPSAwOyBpIDwgbjsgaSsrKQogICAgewogICAgICAgIGNpbiA+PiBhOwogICAgICAgIAogICAgICAgIGlmKGkgPT0gMCkKICAgICAgICAgICAgbWF4ID0gYSwgbWluID0gYTsKICAgICAgICAKICAgICAgICBpZihtYXggPCBhKQogICAgICAgICAgICBtYXggPSBhOwogICAgICAgIAogICAgICAgIGlmKG1pbiA+IGEpCiAgICAgICAgICAgIG1pbiA9IGE7CiAgICB9CiAgICBjb3V0IDw8IG1pbiA8PCAiICIgPDwgbWF4OwogICAgcmV0dXJuIDA7Cn0=