Problem:
Score : 200 points

Problem Statement

You are given an integer sequence A of length N.
Find the maximum absolute difference of two elements (with different indices) in A.

Constraints

2 \leq N \leq 100

1 \leq A_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 ... A_N

Output

Print the maximum absolute difference of two elements (with different indices) in A.

Sample Input 1

4
1 4 6 3

Sample Output 1

5

The maximum absolute difference of two elements is A_3-A_1=6-1=5.

Sample Input 2

2
1000000000 1

Sample Output 2

999999999

Sample Input 3

5
1 1 1 1 1

Sample Output 3

0

Solution in C++14 (GCC 5.4.1) (judge verdict: Runtime Error)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define NUM 128


int main(void){
	int a;
	int i = 0, n = 0, k = 0;
	int min;
	int max;
	char buf[NUM];//初期入力の箱
	int b[a];//数値型の箱
	int len;//文字列の長さ
	char str[NUM];
	char s;//一時格納
	char space[] = " ";

	//入力
	fgets(buf, 127, stdin);
	sscanf(buf, "%d", &a);
	fgets(buf, sizeof(buf), stdin);
	len = strlen(buf);
	//printf("%s %d\n",buf, len);
	

	//文字列を分割、	
	while(len != i)
	{
	s = buf[i];
	//printf("%d: %c\n",i, s);
		//spaceだったら
		if(s == ' ' || i == len-1)
		{
			//数値型に変換
			
			b[n] = atoi(str);
			//printf("%d\n",b[n]);
			n++;
			k = 0;
			//str[]の中身を空にする
			for(int j = 0; j < NUM; j++)
			{
				str[j] = '\0';
			}
			//printf("スペース\n");
		
		}else{
			//文字列連結
			str[k] = s;
			k++;
			//printf("スペースじゃない\n");
		}
		i++;
		//printf("%s\n",str);
	}

	//計算
	min = b[0];
	max = b[0];
	for(int j =0;j<n;j++){
		if(min > b[j]){
			min = b[j];
		}
		if(max < b[j]){
			max = b[j];
		}
	}

	//出力
	printf("%d\n", max - min);

}