const inputs = require("fs").readFileSync(0, "utf8").toString().split("\n");
const n = Number(inputs[0]);
const arr = inputs[1].split(" ").map(Number);
let min=arr[0], max=arr[0];
for (let i=1; i<n; i++){
    if (arr[i]>max) max = arr[i];
    if (arr[i]<min) min = arr[i];
}
console.log(min, max);
