var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n").map(Number);
while(true){
   var n=Arr.shift();
   if(n==0)break;
   var arr=[];
   for(var i=0;i<n;i++)arr.push(Arr.shift());
   arr.sort(function(a,b){return a-b;});
   arr.shift();
   arr.pop();
   var sum=arr.reduce(function(a,b){return a+b;});
   var ave=Math.floor(sum/arr.length);
   console.log(ave);
}