package jp.co.kokou.sample.no275; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.stream.Stream; public class Main { public static void main(String[] args) { try (InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr)) { br.readLine(); // 最初の値は捨てる String[] strNums = br.readLine().split("\\s+"); int[] nums = Stream.of(strNums).mapToInt(Integer::parseInt).toArray(); System.out.format("%.1f%n", Median.calc(nums)); } catch (IOException ex) { } } public static class Median { public static double calc(int... numbers) { int[] nums = Arrays.copyOf(numbers, numbers.length); Arrays.sort(nums); if (nums.length % 2 == 0) { // 偶数 return (nums[nums.length / 2 - 1] + nums[nums.length / 2]) / 2.0; } else { // 奇数 return nums[nums.length / 2]; } } } }