#include<stdio.h>
int main(){
    int n;
     if(scanf("%d", &n) != 1 || n<=0){
         printf("Invalid input");
         return 0;
     }
     int score[n];
     
     for(int i=0;i<n;i++){
         if(scanf("%d", &scores[i]) !=1){
             printf("Invalid input");
             return 0;
         }
     }
     
     int highest=scores[0];
     int lowest=scores[0];
     
     for(int i=1;i<n;i++){
         if(scores[i]>highest)
         highest=scores[i];
         if(scores[i]<lowest)
         lowest=scores[i];
     }
     
     printf("%d",highest+lowest);
     return 0;
}