
import java.util.Scanner;

class Main {
	public static void main(String args[]){
		
		Scanner sc = new Scanner(System.in);
		
		//整数の数nを受け取る
		String s1 = sc.next();
	    int n = Integer.parseInt(s1);
	    int a[] = new int[n];
	    long sum = 0;
	    
	    //n回、整数を読み取り、配列に入れる
	    for(int i = 0; i <= n-1; i++){
	    	String s2 = sc.next();
		    int j = Integer.parseInt(s2);
		    a[i] = j;
	    }
	    
	    //配列の０番目に大きな数、最後に小さな数が来るように並べ変える
	    for(int i = 0; i <= a.length-1; i++){
	    	for(int j = 0; j <= a.length-2; j++){
	    		if(a[j] < a[j+1]){
	    			int w = a[j];
	    			a[j] = a[j+1];
	    			a[j+1] = w;
	    		}
	    	}
	    }
	    
	    //配列に格納されている整数の合計を計算
	    for(int i = 0; i < a.length; i++){
	    	sum = sum + (long)a[i];
	    }
	    
	    //最小値、最大値、合計を表示
	    System.out.println(a[a.length-1] + " " + a[0] + " " + sum);
	}
} import java.util.Scanner; Scanner java.util class Main {
	public static void main(String args[]){
		
		Scanner sc = new Scanner(System.in);
		
		//整数の数nを受け取る
		String s1 = sc.next();
	    int n = Integer.parseInt(s1);
	    int a[] = new int[n];
	    long sum = 0;
	    
	    //n回、整数を読み取り、配列に入れる
	    for(int i = 0; i <= n-1; i++){
	    	String s2 = sc.next();
		    int j = Integer.parseInt(s2);
		    a[i] = j;
	    }
	    
	    //配列の０番目に大きな数、最後に小さな数が来るように並べ変える
	    for(int i = 0; i <= a.length-1; i++){
	    	for(int j = 0; j <= a.length-2; j++){
	    		if(a[j] < a[j+1]){
	    			int w = a[j];
	    			a[j] = a[j+1];
	    			a[j+1] = w;
	    		}
	    	}
	    }
	    
	    //配列に格納されている整数の合計を計算
	    for(int i = 0; i < a.length; i++){
	    	sum = sum + (long)a[i];
	    }
	    
	    //最小値、最大値、合計を表示
	    System.out.println(a[a.length-1] + " " + a[0] + " " + sum);
	}
} Main public static void main(String args[]){
		
		Scanner sc = new Scanner(System.in);
		
		//整数の数nを受け取る
		String s1 = sc.next();
	    int n = Integer.parseInt(s1);
	    int a[] = new int[n];
	    long sum = 0;
	    
	    //n回、整数を読み取り、配列に入れる
	    for(int i = 0; i <= n-1; i++){
	    	String s2 = sc.next();
		    int j = Integer.parseInt(s2);
		    a[i] = j;
	    }
	    
	    //配列の０番目に大きな数、最後に小さな数が来るように並べ変える
	    for(int i = 0; i <= a.length-1; i++){
	    	for(int j = 0; j <= a.length-2; j++){
	    		if(a[j] < a[j+1]){
	    			int w = a[j];
	    			a[j] = a[j+1];
	    			a[j+1] = w;
	    		}
	    	}
	    }
	    
	    //配列に格納されている整数の合計を計算
	    for(int i = 0; i < a.length; i++){
	    	sum = sum + (long)a[i];
	    }
	    
	    //最小値、最大値、合計を表示
	    System.out.println(a[a.length-1] + " " + a[0] + " " + sum);
	} main {
		
		Scanner sc = new Scanner(System.in);
		
		//整数の数nを受け取る
		String s1 = sc.next();
	    int n = Integer.parseInt(s1);
	    int a[] = new int[n];
	    long sum = 0;
	    
	    //n回、整数を読み取り、配列に入れる
	    for(int i = 0; i <= n-1; i++){
	    	String s2 = sc.next();
		    int j = Integer.parseInt(s2);
		    a[i] = j;
	    }
	    
	    //配列の０番目に大きな数、最後に小さな数が来るように並べ変える
	    for(int i = 0; i <= a.length-1; i++){
	    	for(int j = 0; j <= a.length-2; j++){
	    		if(a[j] < a[j+1]){
	    			int w = a[j];
	    			a[j] = a[j+1];
	    			a[j+1] = w;
	    		}
	    	}
	    }
	    
	    //配列に格納されている整数の合計を計算
	    for(int i = 0; i < a.length; i++){
	    	sum = sum + (long)a[i];
	    }
	    
	    //最小値、最大値、合計を表示
	    System.out.println(a[a.length-1] + " " + a[0] + " " + sum);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s1 = sc.next(); s1 sc.next() sc.next sc int n = Integer.parseInt(s1); n Integer.parseInt(s1) Integer.parseInt Integer s1 int a[] = new int[n]; a new int[n] n long sum = 0; sum 0 for(int i = 0; i <= n-1; i++){
	    	String s2 = sc.next();
		    int j = Integer.parseInt(s2);
		    a[i] = j;
	    } int i = 0; int i = 0; i 0 i <= n-1 i n-1 n 1 i++ i++ i {
	    	String s2 = sc.next();
		    int j = Integer.parseInt(s2);
		    a[i] = j;
	    } {
	    	String s2 = sc.next();
		    int j = Integer.parseInt(s2);
		    a[i] = j;
	    } String s2 = sc.next(); s2 sc.next() sc.next sc int j = Integer.parseInt(s2); j Integer.parseInt(s2) Integer.parseInt Integer s2 a[i] = j a[i] a i j for(int i = 0; i <= a.length-1; i++){
	    	for(int j = 0; j <= a.length-2; j++){
	    		if(a[j] < a[j+1]){
	    			int w = a[j];
	    			a[j] = a[j+1];
	    			a[j+1] = w;
	    		}
	    	}
	    } int i = 0; int i = 0; i 0 i <= a.length-1 i a.length-1 a.length a a.length 1 i++ i++ i {
	    	for(int j = 0; j <= a.length-2; j++){
	    		if(a[j] < a[j+1]){
	    			int w = a[j];
	    			a[j] = a[j+1];
	    			a[j+1] = w;
	    		}
	    	}
	    } {
	    	for(int j = 0; j <= a.length-2; j++){
	    		if(a[j] < a[j+1]){
	    			int w = a[j];
	    			a[j] = a[j+1];
	    			a[j+1] = w;
	    		}
	    	}
	    } for(int j = 0; j <= a.length-2; j++){
	    		if(a[j] < a[j+1]){
	    			int w = a[j];
	    			a[j] = a[j+1];
	    			a[j+1] = w;
	    		}
	    	} int j = 0; int j = 0; j 0 j <= a.length-2 j a.length-2 a.length a a.length 2 j++ j++ j {
	    		if(a[j] < a[j+1]){
	    			int w = a[j];
	    			a[j] = a[j+1];
	    			a[j+1] = w;
	    		}
	    	} {
	    		if(a[j] < a[j+1]){
	    			int w = a[j];
	    			a[j] = a[j+1];
	    			a[j+1] = w;
	    		}
	    	} if(a[j] < a[j+1]){
	    			int w = a[j];
	    			a[j] = a[j+1];
	    			a[j+1] = w;
	    		} a[j] < a[j+1] a[j] a j a[j+1] a j+1 j 1 {
	    			int w = a[j];
	    			a[j] = a[j+1];
	    			a[j+1] = w;
	    		} int w = a[j]; w a[j] a j a[j] = a[j+1] a[j] a j a[j+1] a j+1 j 1 a[j+1] = w a[j+1] a j+1 j 1 w for(int i = 0; i < a.length; i++){
	    	sum = sum + (long)a[i];
	    } int i = 0; int i = 0; i 0 i < a.length i a.length a a.length i++ i++ i {
	    	sum = sum + (long)a[i];
	    } {
	    	sum = sum + (long)a[i];
	    } sum = sum + (long)a[i] sum sum + (long)a[i] sum (long)a[i] a i System.out.println(a[a.length-1] + " " + a[0] + " " + sum) System.out.println System.out System System.out a[a.length-1] + " " + a[0] + " " + sum " " a[0] a[a.length-1] + " " + a[0] + " " + sum a[a.length-1] a a.length-1 a.length a a.length 1 " " a[0] a 0 " " sum String args[] args

import java.util.Scanner;

class Main {
	public static void main(String args[]){
		
		Scanner sc = new Scanner(System.in);
		
		//整数の数nを受け取る
		String s1 = sc.next();
	    int n = Integer.parseInt(s1);
	    int a[] = new int[n];
	    long sum = 0;
	    
	    //n回、整数を読み取り、配列に入れる
	    for(int i = 0; i <= n-1; i++){
	    	String s2 = sc.next();
		    int j = Integer.parseInt(s2);
		    a[i] = j;
	    }
	    
	    //配列の０番目に大きな数、最後に小さな数が来るように並べ変える
	    for(int i = 0; i <= a.length-1; i++){
	    	for(int j = 0; j <= a.length-2; j++){
	    		if(a[j] < a[j+1]){
	    			int w = a[j];
	    			a[j] = a[j+1];
	    			a[j+1] = w;
	    		}
	    	}
	    }
	    
	    //配列に格納されている整数の合計を計算
	    for(int i = 0; i < a.length; i++){
	    	sum = sum + (long)a[i];
	    }
	    
	    //最小値、最大値、合計を表示
	    System.out.println(a[a.length-1] + " " + a[0] + " " + sum);
	}
}