import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		String str1 = scan.nextLine();
		String str2 = scan.nextLine();
		scan.close();

		int n = Integer.parseInt(str1);
		String[] ai = str2.split(" ", 0);

		int sVal = 0;
		int min = Integer.parseInt(ai[0]);
		for (int i = 0; i < n - 1; i++) {
			int num1 = Integer.parseInt(ai[i]);
			int num2 = Integer.parseInt(ai[i + 1]);
			if (num1 <= num2) {
				sVal = num1;
			} else {
				sVal = num2;
			}
			if (sVal <= min) {
				min = sVal;
			}
		}

		int bVal = 0;
		int max = Integer.parseInt(ai[0]);
		for (int i = 0; i < n - 1; i++) {
			int num1 = Integer.parseInt(ai[i]);
			int num2 = Integer.parseInt(ai[i + 1]);
			if (num1 <= num2) {
				bVal = num2;
			} else {
				bVal = num1;
			}
			if (max <= bVal) {
				max = bVal;
			}
		}

		long sum = Integer.parseInt(ai[0]);
		for (int i = 1; i < n; i++) {
			long num = Integer.parseInt(ai[i]);
			sum += num;
		}

		System.out.println(min + " " + max + " " + sum);

	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		String str1 = scan.nextLine();
		String str2 = scan.nextLine();
		scan.close();

		int n = Integer.parseInt(str1);
		String[] ai = str2.split(" ", 0);

		int sVal = 0;
		int min = Integer.parseInt(ai[0]);
		for (int i = 0; i < n - 1; i++) {
			int num1 = Integer.parseInt(ai[i]);
			int num2 = Integer.parseInt(ai[i + 1]);
			if (num1 <= num2) {
				sVal = num1;
			} else {
				sVal = num2;
			}
			if (sVal <= min) {
				min = sVal;
			}
		}

		int bVal = 0;
		int max = Integer.parseInt(ai[0]);
		for (int i = 0; i < n - 1; i++) {
			int num1 = Integer.parseInt(ai[i]);
			int num2 = Integer.parseInt(ai[i + 1]);
			if (num1 <= num2) {
				bVal = num2;
			} else {
				bVal = num1;
			}
			if (max <= bVal) {
				max = bVal;
			}
		}

		long sum = Integer.parseInt(ai[0]);
		for (int i = 1; i < n; i++) {
			long num = Integer.parseInt(ai[i]);
			sum += num;
		}

		System.out.println(min + " " + max + " " + sum);

	}
} Main public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		String str1 = scan.nextLine();
		String str2 = scan.nextLine();
		scan.close();

		int n = Integer.parseInt(str1);
		String[] ai = str2.split(" ", 0);

		int sVal = 0;
		int min = Integer.parseInt(ai[0]);
		for (int i = 0; i < n - 1; i++) {
			int num1 = Integer.parseInt(ai[i]);
			int num2 = Integer.parseInt(ai[i + 1]);
			if (num1 <= num2) {
				sVal = num1;
			} else {
				sVal = num2;
			}
			if (sVal <= min) {
				min = sVal;
			}
		}

		int bVal = 0;
		int max = Integer.parseInt(ai[0]);
		for (int i = 0; i < n - 1; i++) {
			int num1 = Integer.parseInt(ai[i]);
			int num2 = Integer.parseInt(ai[i + 1]);
			if (num1 <= num2) {
				bVal = num2;
			} else {
				bVal = num1;
			}
			if (max <= bVal) {
				max = bVal;
			}
		}

		long sum = Integer.parseInt(ai[0]);
		for (int i = 1; i < n; i++) {
			long num = Integer.parseInt(ai[i]);
			sum += num;
		}

		System.out.println(min + " " + max + " " + sum);

	} main {
		Scanner scan = new Scanner(System.in);
		String str1 = scan.nextLine();
		String str2 = scan.nextLine();
		scan.close();

		int n = Integer.parseInt(str1);
		String[] ai = str2.split(" ", 0);

		int sVal = 0;
		int min = Integer.parseInt(ai[0]);
		for (int i = 0; i < n - 1; i++) {
			int num1 = Integer.parseInt(ai[i]);
			int num2 = Integer.parseInt(ai[i + 1]);
			if (num1 <= num2) {
				sVal = num1;
			} else {
				sVal = num2;
			}
			if (sVal <= min) {
				min = sVal;
			}
		}

		int bVal = 0;
		int max = Integer.parseInt(ai[0]);
		for (int i = 0; i < n - 1; i++) {
			int num1 = Integer.parseInt(ai[i]);
			int num2 = Integer.parseInt(ai[i + 1]);
			if (num1 <= num2) {
				bVal = num2;
			} else {
				bVal = num1;
			}
			if (max <= bVal) {
				max = bVal;
			}
		}

		long sum = Integer.parseInt(ai[0]);
		for (int i = 1; i < n; i++) {
			long num = Integer.parseInt(ai[i]);
			sum += num;
		}

		System.out.println(min + " " + max + " " + sum);

	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String str1 = scan.nextLine(); str1 scan.nextLine() scan.nextLine scan String str2 = scan.nextLine(); str2 scan.nextLine() scan.nextLine scan scan.close() scan.close scan int n = Integer.parseInt(str1); n Integer.parseInt(str1) Integer.parseInt Integer str1 String[] ai = str2.split(" ", 0); ai str2.split(" ", 0) str2.split str2 " " 0 int sVal = 0; sVal 0 int min = Integer.parseInt(ai[0]); min Integer.parseInt(ai[0]) Integer.parseInt Integer ai[0] ai 0 for (int i = 0; i < n - 1; i++) {
			int num1 = Integer.parseInt(ai[i]);
			int num2 = Integer.parseInt(ai[i + 1]);
			if (num1 <= num2) {
				sVal = num1;
			} else {
				sVal = num2;
			}
			if (sVal <= min) {
				min = sVal;
			}
		} int i = 0; int i = 0; i 0 i < n - 1 i n - 1 n 1 i++ i++ i {
			int num1 = Integer.parseInt(ai[i]);
			int num2 = Integer.parseInt(ai[i + 1]);
			if (num1 <= num2) {
				sVal = num1;
			} else {
				sVal = num2;
			}
			if (sVal <= min) {
				min = sVal;
			}
		} {
			int num1 = Integer.parseInt(ai[i]);
			int num2 = Integer.parseInt(ai[i + 1]);
			if (num1 <= num2) {
				sVal = num1;
			} else {
				sVal = num2;
			}
			if (sVal <= min) {
				min = sVal;
			}
		} int num1 = Integer.parseInt(ai[i]); num1 Integer.parseInt(ai[i]) Integer.parseInt Integer ai[i] ai i int num2 = Integer.parseInt(ai[i + 1]); num2 Integer.parseInt(ai[i + 1]) Integer.parseInt Integer ai[i + 1] ai i + 1 i 1 if (num1 <= num2) {
				sVal = num1;
			} else {
				sVal = num2;
			} num1 <= num2 num1 num2 {
				sVal = num1;
			} sVal = num1 sVal num1 {
				sVal = num2;
			} sVal = num2 sVal num2 if (sVal <= min) {
				min = sVal;
			} sVal <= min sVal min {
				min = sVal;
			} min = sVal min sVal int bVal = 0; bVal 0 int max = Integer.parseInt(ai[0]); max Integer.parseInt(ai[0]) Integer.parseInt Integer ai[0] ai 0 for (int i = 0; i < n - 1; i++) {
			int num1 = Integer.parseInt(ai[i]);
			int num2 = Integer.parseInt(ai[i + 1]);
			if (num1 <= num2) {
				bVal = num2;
			} else {
				bVal = num1;
			}
			if (max <= bVal) {
				max = bVal;
			}
		} int i = 0; int i = 0; i 0 i < n - 1 i n - 1 n 1 i++ i++ i {
			int num1 = Integer.parseInt(ai[i]);
			int num2 = Integer.parseInt(ai[i + 1]);
			if (num1 <= num2) {
				bVal = num2;
			} else {
				bVal = num1;
			}
			if (max <= bVal) {
				max = bVal;
			}
		} {
			int num1 = Integer.parseInt(ai[i]);
			int num2 = Integer.parseInt(ai[i + 1]);
			if (num1 <= num2) {
				bVal = num2;
			} else {
				bVal = num1;
			}
			if (max <= bVal) {
				max = bVal;
			}
		} int num1 = Integer.parseInt(ai[i]); num1 Integer.parseInt(ai[i]) Integer.parseInt Integer ai[i] ai i int num2 = Integer.parseInt(ai[i + 1]); num2 Integer.parseInt(ai[i + 1]) Integer.parseInt Integer ai[i + 1] ai i + 1 i 1 if (num1 <= num2) {
				bVal = num2;
			} else {
				bVal = num1;
			} num1 <= num2 num1 num2 {
				bVal = num2;
			} bVal = num2 bVal num2 {
				bVal = num1;
			} bVal = num1 bVal num1 if (max <= bVal) {
				max = bVal;
			} max <= bVal max bVal {
				max = bVal;
			} max = bVal max bVal long sum = Integer.parseInt(ai[0]); sum Integer.parseInt(ai[0]) Integer.parseInt Integer ai[0] ai 0 for (int i = 1; i < n; i++) {
			long num = Integer.parseInt(ai[i]);
			sum += num;
		} int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
			long num = Integer.parseInt(ai[i]);
			sum += num;
		} {
			long num = Integer.parseInt(ai[i]);
			sum += num;
		} long num = Integer.parseInt(ai[i]); num Integer.parseInt(ai[i]) Integer.parseInt Integer ai[i] ai i sum += num sum num System.out.println(min + " " + max + " " + sum) System.out.println System.out System System.out min + " " + max + " " + sum " " max min + " " + max + " " + sum min " " max " " sum String args[] args public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		String str1 = scan.nextLine();
		String str2 = scan.nextLine();
		scan.close();

		int n = Integer.parseInt(str1);
		String[] ai = str2.split(" ", 0);

		int sVal = 0;
		int min = Integer.parseInt(ai[0]);
		for (int i = 0; i < n - 1; i++) {
			int num1 = Integer.parseInt(ai[i]);
			int num2 = Integer.parseInt(ai[i + 1]);
			if (num1 <= num2) {
				sVal = num1;
			} else {
				sVal = num2;
			}
			if (sVal <= min) {
				min = sVal;
			}
		}

		int bVal = 0;
		int max = Integer.parseInt(ai[0]);
		for (int i = 0; i < n - 1; i++) {
			int num1 = Integer.parseInt(ai[i]);
			int num2 = Integer.parseInt(ai[i + 1]);
			if (num1 <= num2) {
				bVal = num2;
			} else {
				bVal = num1;
			}
			if (max <= bVal) {
				max = bVal;
			}
		}

		long sum = Integer.parseInt(ai[0]);
		for (int i = 1; i < n; i++) {
			long num = Integer.parseInt(ai[i]);
			sum += num;
		}

		System.out.println(min + " " + max + " " + sum);

	}
} public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		String str1 = scan.nextLine();
		String str2 = scan.nextLine();
		scan.close();

		int n = Integer.parseInt(str1);
		String[] ai = str2.split(" ", 0);

		int sVal = 0;
		int min = Integer.parseInt(ai[0]);
		for (int i = 0; i < n - 1; i++) {
			int num1 = Integer.parseInt(ai[i]);
			int num2 = Integer.parseInt(ai[i + 1]);
			if (num1 <= num2) {
				sVal = num1;
			} else {
				sVal = num2;
			}
			if (sVal <= min) {
				min = sVal;
			}
		}

		int bVal = 0;
		int max = Integer.parseInt(ai[0]);
		for (int i = 0; i < n - 1; i++) {
			int num1 = Integer.parseInt(ai[i]);
			int num2 = Integer.parseInt(ai[i + 1]);
			if (num1 <= num2) {
				bVal = num2;
			} else {
				bVal = num1;
			}
			if (max <= bVal) {
				max = bVal;
			}
		}

		long sum = Integer.parseInt(ai[0]);
		for (int i = 1; i < n; i++) {
			long num = Integer.parseInt(ai[i]);
			sum += num;
		}

		System.out.println(min + " " + max + " " + sum);

	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		String str1 = scan.nextLine();
		String str2 = scan.nextLine();
		scan.close();

		int n = Integer.parseInt(str1);
		String[] ai = str2.split(" ", 0);

		int sVal = 0;
		int min = Integer.parseInt(ai[0]);
		for (int i = 0; i < n - 1; i++) {
			int num1 = Integer.parseInt(ai[i]);
			int num2 = Integer.parseInt(ai[i + 1]);
			if (num1 <= num2) {
				sVal = num1;
			} else {
				sVal = num2;
			}
			if (sVal <= min) {
				min = sVal;
			}
		}

		int bVal = 0;
		int max = Integer.parseInt(ai[0]);
		for (int i = 0; i < n - 1; i++) {
			int num1 = Integer.parseInt(ai[i]);
			int num2 = Integer.parseInt(ai[i + 1]);
			if (num1 <= num2) {
				bVal = num2;
			} else {
				bVal = num1;
			}
			if (max <= bVal) {
				max = bVal;
			}
		}

		long sum = Integer.parseInt(ai[0]);
		for (int i = 1; i < n; i++) {
			long num = Integer.parseInt(ai[i]);
			sum += num;
		}

		System.out.println(min + " " + max + " " + sum);

	}
}