use strict; use warnings; use feature qw/say/; # https://yukicoder.me/problems/746 my $N = <>; # my $N = 6; my $A = <>; # my $A = "1 2 3 4 5 6"; my @a = sort ( split / /, $A ); my $index = int( $N / 2 ); # 与えられる数が偶数か奇数で分ける if ( $N % 2 == 0 ) { # 偶数 my $central_sum = $a[$index - 1] + $a[$index]; say $central_sum / 2; } else { # 奇数 say $a[$index]; }