import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UncheckedIOException; import java.util.stream.Stream; class Main { public static void main(String[] args) { no21(); } // No.21 平均の差 private static void no21(){ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); // 数字の個数 int totalNumber; // グループ数 String groups; // 数字 String[] inputNumbers; try { String tn = reader.readLine(); totalNumber = Integer.parseInt(tn); groups = reader.readLine(); inputNumbers = new String[totalNumber]; for(int i = 0; i < totalNumber; i++){ inputNumbers[i] = reader.readLine(); } reader.close(); } catch (IOException e) { throw new UncheckedIOException(e); } int[] numbers = Stream.of(inputNumbers).mapToInt(Integer::parseInt).sorted().toArray(); // 平均の差を求める System.out.println(numbers[totalNumber - 1] - numbers[0]); } }