#include <fstream>
#include <cstdint>

using namespace std;

ifstream input("Bai3_17.inp");
ofstream output("Bai3_17.out");

int main()
{
	int n;
	input >> n;
	int a;
	int max = INT32_MIN;
	int min = INT32_MAX;
	for (int i = 0; i < n; ++i)
	{
		input >> a;
		if (a > max) max = a;
		if (a < min) min = a;
	}
	output << max + min;
	input.close();
	output.close();
	return 0;
}