Go: /*
	Problem A: ICPC 得点集計ソフトウェア
	http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// 標準入力を取得するScannerのインスタンスを作成
var sc = bufio.NewScanner(os.Stdin)

// 標準入力で各行を読み込み文字列として返す
func readLine() string {
	if sc.Scan() {
		return sc.Text()
	}
	return ""
}

func average() (avg int) {
	// 審判の人数を取得する
	n, _ := strconv.Atoi(readLine())

	// 得点
	score := make([]int, 0, n)

	// 得点を読み込む
	for n > 0 {
		line, _ := strconv.Atoi(readLine())
		score = append(score, line)
		n--
	}

	if len(score) == 0 {
		return 0
	}

	// ソート
	sort.Ints(score)
	// 先頭を削除
	score = append(score[:0], score[1:]...)
	// 末尾を削除
	score = score[:len(score)-1]

	// 合計
	for i := 0; i < len(score); i++ {
		avg += score[i]
	}

	// 平均
	avg = avg / len(score)
	return avg
}

func main() {
	// 改行区切りから単語(スペース)区切りで読み込むように変更する
	sc.Split(bufio.ScanWords)
	for {
		avg := average()
		if avg != 0 {
			fmt.Println(avg)
		} else {
			break
		}
	}
}

C++: #include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    int n;
    while(true){
        cin>>n;
        if(n==0)break;
        vector<int> v(n);
        int sum=0;
        rep(i,n){
            cin>>v[i];
            sum+=v[i];
        }
        sort(v.begin(),v.end());
        sum-=v[0];
        sum-=v[n-1];
        int ave=sum/(n-2);
        cout<<ave<<endl;


    }

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define lout cout
#else
stringstream devnull;
#define lout devnull
#endif
template <class C>
inline void vcin(C &a);
template <class C>
inline void vcout(const C a, const string separate = "\n");

int main()
{
  while (true)
  {
    int n;
    cin >> n;
    if (n == 0)
    {
      break;
    }
    vector<int> s(n);
    vcin(s);
    sort(s.begin(), s.end());
    s.erase(s.begin());
    s.pop_back();
    cout << accumulate(s.begin(), s.end(), 0) / s.size() << endl;
  }
  return 0;
}

template <class C>
inline void vcin(C &c)
{
  for (auto &a : c)
  {
    cin >> a;
  }
}
template <class C>
inline void vcout(const C c, const string separate)
{
  for (auto it = c.begin(); it != c.end(); it++)
  {
    if (it != c.begin())
      cout << separate;
    cout << *it;
  }
}

C++: #include <queue>//priority_queue
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <array>
#include <map>
#include <list>
#include <set>
#include <utility>
#include <vector>
#include <cmath>
#include <bitset>
#include <iostream>

#pragma warning(disable: 4996)

/*-------マクロ定義---------*/

#define REP(i , n) for(L i = 0 ; i < n ; i++)
#define TIMES(n) REP(i , n)


/*---------Typedef------------*/

//long
typedef long L;
typedef std::pair<L, L>				IntPair;
typedef std::vector<L>				IntVector;
typedef std::priority_queue<L>		IntPriority;
typedef std::queue<L>				IntQueue;
typedef std::stack<L>				IntStack;

//unsigned long
typedef unsigned long ul;
typedef std::pair<ul, ul>			UIntPair;
typedef std::vector<ul>				UIntVector;
typedef std::priority_queue<ul>		UIntPriority;
typedef std::queue<ul>				UIntQueue;
typedef std::stack<ul>				UIntStack;

//double
typedef double D;
typedef std::pair<D, D>				DoublePair;
typedef std::vector<D>				DoubleVector;
typedef std::priority_queue<D>		DoublePriority;
typedef std::queue<D>				DoubleQueue;
typedef std::stack<D>				DoubleStack;

//char
typedef char Ch;
typedef std::pair<Ch, Ch>			CharPair;
typedef std::vector<Ch>				CharVector;
typedef std::priority_queue<Ch>		CharPriority;
typedef std::queue<Ch>				CharQueue;
typedef std::stack<Ch>				CharStack;

//
/*  VectorArray	Dp(1000,IntVector(1000)); */
typedef std::vector<std::vector<L>>		VectorArray;
typedef std::vector<std::vector<ul>>	UVectorArray;
typedef std::vector<std::vector<D>>		DVectorArray;


/*--------ScanOverLoad----------*/

//type long//

void Scan(L& output)
{
	scanf("%ld", &output);
}

void Scan(IntVector& vector)
{
	L scan = 0;
	scanf("%ld", &scan);
	vector.push_back(scan);
}

void Scan(IntPriority& pri_que)
{
	L scan = 0;
	scanf("%ld", &scan);
	pri_que.push(scan);
}

void Scan(IntQueue& que)
{
	L scan = 0;
	scanf("%ld", &scan);
	que.push(scan);
}

void Scan(IntStack& stack)
{
	L scan = 0;
	scanf("%ld",&scan);
	stack.push(scan);
}

//type unsigned long//

void Scan(ul& output)
{
	scanf("%lu", &output);
}

void Scan(UIntVector& vector)
{
	ul scan = 0;
	scanf("%lu", &scan);
	vector.push_back(scan);
}

void Scan(UIntPriority& pri_que)
{
	ul scan = 0;
	scanf("%lu", &scan);
	pri_que.push(scan);
}

void Scan(UIntQueue& que)
{
	ul scan = 0;
	scanf("%lu", &scan);
	que.push(scan);
}

void Scan(UIntStack& stack)
{
	ul scan = 0;
	scanf("%lu", &scan);
	stack.push(scan);
}

//type double//

void Scan(D& output)
{
	scanf("%lf", &output);
}

void Scan(DoubleVector& vector)
{
	D scan = 0;
	scanf("lf", &scan);
	vector.push_back(scan);
}

void Scan(DoublePriority& pri_que)
{
	D scan = 0;
	scanf("%lf", &scan);
	pri_que.push(scan);
}

void Scan(DoubleQueue& que)
{
	D scan = 0;
	scanf("%lf", &scan);
	que.push(scan);
}

void Scan(DoubleStack& stack)
{
	D scan = 0;
	scanf("%lf", &scan);
	stack.push(scan);
}

//type char//

void Scan(Ch& output)
{
	scanf("%c", &output);
}

void Scan(CharVector& vector)
{
	Ch scan = 0;
	scanf("%c", &scan);
	vector.push_back(scan);
}

void Scan(CharPriority& pri_que)
{
	Ch scan = 0;
	scanf("%c", &scan);
	pri_que.push(scan);
}

void Scan(CharQueue& que)
{
	Ch scan = 0;
	scanf("%c", &scan);
	que.push(scan);
}

void Scan(CharStack& stack)
{
	Ch scan = 0;
	scanf("%c", &scan);
	stack.push(scan);
}

/*----------Print----------*/

struct OPrint{
	void operator()(L& value)		{ printf("%ld", value); }
	void operator()(ul& value)		{ printf("%lu", value); }
	void operator()(D& value)		{ printf("%lf", value); }
	void operator()(Ch& value)		{ printf("%c", value); }
};

template<class T>
void Print(T& value){ std::for_each(value.begin(), value.end(), OPrint()); }

void Print(L value){ printf("%ld", value); }

void Print(ul value){ printf("%lu", value); }

void Print(D value){ printf("%lf", value); }

void Print(Ch value){ printf("%c", value); }

/*----------Init---------*/

template<class T>
struct OInit{
	T x;

	OInit(T _x) :x(_x){}

	void operator()(L& value)	{ value = x; }
	void operator()(ul& value)	{ value = x; }
	void operator()(D& value)	{ value = x; }
	void operator()(Ch& value)	{ value = x; }
};

template<class T1 , class T2>
void Init(T1& value,T2 x){ std::for_each(value.begin(), value.end(), OInit<T2>(x)); }

void Init(L& value, L x){ value = x; }

void Init(ul& value, ul x){ value = x; }

void Init(D& value, D x){ value = x; }

void Init(Ch& value, Ch x){ value = x; }



int main()
{
	for (;;){
		IntVector Point;
		L n; Scan(n);
		if (!n) return 0;

		TIMES(n)
			Scan(Point);
		std::sort(Point.begin() , Point.end());
		
		L souwa = 0;

		std::for_each(Point.begin() + 1, Point.end() - 1, [&souwa](L x){
			souwa += x;
		});
			Print(souwa / (Point.size()-2));
			puts("");
	}

	return 0;
}