function Main(input) { var line = input.split("\n"); var N = +line[0]; var A = line[1]; sort(N,A) } function sort(N,A){ var migawari; var sortFin = false; var sorted = 0; while (sortFin == false) { sorted = 0; for (var j = 0; j < A.length; j++) { if (+A[j] > +A[j + 1]) { migawari = +A[j] A[j] = 0; A[j] = +A[j + 1]; A[j + 1] = 0; A[j + 1] = migawari; } else { sorted += 1 sortFin = (sorted == A.length - 1) ? true : false; } } } medCalc(N,A) } function medCalc(N,A){ var med; var i = Math.ceil((N - 1) / 2) if (N % 2 == 1) { console.log(+A[i]); } else { med = Math.floor((parseInt(A[i]) + parseInt(A[i + 1]) / 2 * 10)) / 10; console.log(med) } } Main(require("fs").readFileSync("/dev/stdin", "utf8"));