#include <bits/stdc++.h>

using namespace std;

ifstream fi ("bai3_17.inp");
ofstream fo ("bai3_17.out");

int main(){
   int n;
   fi>>n;
   int i,a[n],maxx,minn;
   fi>>a[0];
   maxx=a[0],minn=a[0];
   for (i=1;i<n;i++){
    fi>>a[i];
    maxx=max(maxx,a[i]);
    minn=min(minn,a[i]);
   }
 fo<<maxx+minn;
}
