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 C (judge verdict: Accepted)

//n個の整数 ai(i=1,2,...n)を入力し、それらの最小値、最大値、合計値を求めるプログラム
// Input
// １行目に整数の数 n が与えられます。２行目に n 個の整数 ai が空白区切りで与えられます。
// Output
// 最小値、最大値、合計値を空白区切りで１行に出力してください。

#include <stdio.h>

#define INPUT_MAX_NUMBER 10000

int main(void)
{
    //変数定義
    int iInputNumber;
    int iMin;
    int iMax;
    long long iSum;
    int iCount;
    int iBubleCount;
    int iTemporary;
    int aiData[INPUT_MAX_NUMBER];

    //変数の初期化
    iInputNumber = 0;
    iMax = 0;
    iMin = 0;
    iSum = 0;
    iTemporary = 0; 

    scanf ("%d",&iInputNumber);

    for (iCount = 0; iCount < iInputNumber; iCount++)
    {
        scanf("%d",&aiData[iCount]);
       // printf("%d ",aiData[iCount]); 
    }

    //バブルソート
    for (iCount = 0; iCount < iInputNumber; iCount++)
    {
        for (iBubleCount = iCount; iBubleCount < iInputNumber; iBubleCount++)
        {
            if (aiData[iCount] > aiData[iBubleCount])
            {
                iTemporary = aiData[iCount];
                aiData[iCount] = aiData[iBubleCount];
                aiData[iBubleCount] = iTemporary;
            }
            else if (aiData[iCount] == aiData[iBubleCount])
            {
                //何もしない
            }
            else
            {
                //何もしない
            }
            
        }
    }

    //合計値を計算
    for (iCount = 0; iCount < iInputNumber; iCount++)
    {
        iSum += aiData[iCount];
    }

    iMin = aiData[0];
    iMax = aiData[iInputNumber - 1];

    printf("%d %d %lld\n",iMin,iMax,iSum);
    


    return 0;
}