#include<bits/stdc++.h>
using namespace std;
int main()
{
    freopen("bai3_17.inp","r",stdin);
    freopen("bai3_17.out","w",stdout);
    int64_t n;
    cin>>n;
    int64_t a[n+1];
    for(int64_t i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    cout<<a[1]+a[n];
}
