Problem:
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

Min, Max and Sum

Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.

Input

In the first line, an integer $n$ is given. In the next line, $n$ integers $a_i$ are given in a line.

Output

Print the minimum value, maximum value and sum in a line. Put a single space between the values.

Constraints

$0 < n \leq 10000$

$-1000000 \leq a_i \leq 1000000$

Sample Input

5
10 1 5 4 17

Sample Output

1 17 37

Solution in JAVA (judge verdict: Accepted)

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {
	public static void main(String[] args) throws Exception {
		int eNum;//????????????????´???°????´???¨

		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);

		String str = br.readLine();//????????????????´???°???????´?
		eNum = Integer.parseInt(str);

		String[] element = new String[eNum];

		str = br.readLine();
		element = getElement(str);//????????????????´????????´?

		System.out.println(getMin(element, eNum) + " " +
				getMax(element, eNum) + " " + getSum(element, eNum));
	}

	//?????§???????±???????????????????
	public static int getMax(String[] element, int num) {
		int max = Integer.parseInt(element[0]);
		for (int i = 0; i < num; i++) {
			max = Math.max(max, Integer.parseInt(element[i]));
		}
		return (max);
	}

	//????°????????±???????????????????
	public static int getMin(String[] element, int num) {
		int min = Integer.parseInt(element[0]);
		for (int i = 0; i < num; i++) {
			min = Math.min(min, Integer.parseInt(element[i]));
		}
		return (min);
	}

	//????¨?????±???????????????????
	public static BigDecimal getSum(String[] element, int num) {
		BigDecimal sum = new BigDecimal("0");

		for (int i = 0; i < num; i++) {
			sum = sum.add(new BigDecimal(element[i]));
//			System.out.println("i="+i+" "+element[i]);
		}
		return (sum);
	}

	//??????????????????????????????????????????
	public static String[] getElement(String element) {
		return (element.split(" "));
	}

}