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

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for	{
		n := nextInt(sc)
		if n == 0 { break }

		score_list := []int{}
		for i := 0; i < n; i++ {
			score_list = append(score_list, nextInt(sc))
		}

		// 最低点と最高点を取り除く (3 ≤ n ≤ 100)
		sort.Sort(sort.IntSlice(score_list))
		score_list = score_list[1:len(score_list)-1]

		// 平均点を求める
		sum := 0
		for _, score := range score_list {
			sum += score
		}
		fmt.Println(sum / len(score_list))
	}
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
using namespace std;

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

#define int int64_t

#define REP(i,f,n) for(int i=(f); i < (n); ++i)
#define PER(i,f,n) for(int i=(n-1); i >= f; --i)

constexpr int dx[4] = { 1, 0, -1, 0 };
constexpr int dy[4] = { 0, 1, 0, -1 };

template<typename STL> inline void print_STL(STL c, string ab = ""){
	cout << ab << '\n';
	for(auto t : c) cout << t << ' '; cout << '\n';}

template<typename VEC> inline void import_VEC(VEC& c, int n){
	typename VEC::value_type tmp;
	for(int i = 0; i < n; ++i){	cin >> tmp; c.push_back(tmp);} }

#define SPRE(x) setprecision(x) // 精度を指定

template<class T>	using Matrix = vector<vector<T>>;

signed main()
{
	cin.tie(0);
    ios::sync_with_stdio(false);
	int n;
	while(cin >> n)
	{
		if(n == 0)
			return 0;
		int maxi = 0, mini = INF;
		int sum = 0;
		REP(i, 0, n)
		{
			int tmp;
			cin >> tmp;
			sum += tmp;
			if(maxi < tmp)
				maxi = tmp;
			if(mini > tmp)
				mini = tmp;
		}
		sum -= maxi + mini;
		cout << sum / (n-2) << endl;;
	}

}

C++: #include <iostream>
#include <vector>
using namespace std;

int main(){
    while (1){
	int n;
	vector<int> s;
	
	cin >> n;
	if (n == 0) break;
	int t;
	for (int i = 0; i < n; i++){
	    cin >> t;
	    s.push_back(t);
	}
	sort(s.begin(), s.end());

	int score = 0;
	for (int i = 1; i < s.size() - 1; i++){
	    score += s[i];
	}
	score /= s.size() - 2;

	cout << score << endl;
    }
}

C++: #include<bits/stdc++.h>
#define SIZE 100005
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,s[105];

int main(){
	cin >> n;
	for(int i=0;i<n;i++) cin >>s[i];
	sort(s,s+n);
	int sum=0,m=0;
	for(int i=1;i<n-1;i++) sum+=s[i];
	sum=sum/(n-2);
	cout <<sum<<endl;
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    while (cin >> n, n)
    {
        int a[n];
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
        }

        sort(a, a + n);

        int sum = 0;
        for (int i = 1; i < n - 1; i++)
        {
            sum += a[i];
        }

        cout << sum / (n - 2) << "\n";
    }
}

C++: #include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
  long long N,ans=0;
  while(cin>>N,N){
    ans=0;
  vector<long long> v(N);
  rep(i,N){
    cin>>v[i];
  }
  sort(v.begin(),v.end());
  for(int i=1;i<N-1;i++)ans+=v[i];
  cout<<ans/(N-2)<<endl;
  }
 return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){
    while(1){
        int n;    cin>>n;
        if(n==0)break;

        int s[n];
        for(int i=0;i<n;i++){
            cin>>s[i];
        }

        int max=0,min=1000;;

        for(int i=0;i<n;i++){
            if(s[i]>max)max=s[i];
            if(s[i]<min)min=s[i];
        }
        
        int sum=0;
        for(int i=0;i<n;i++){
            sum +=s [i];
        }


        sum -=max;
        sum -=min;

        cout<<sum/(n-2)<<endl;
    }

    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include <functional>
#include <queue>
#include <regex>
#include<time.h>

using namespace std;


#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;


/*vectorの要素を全部確認するやつだよ。普通に拡張for文したほうがいいよ。

for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}

*/


/*for文でx,yを上下左右確認するやつだよ。正直使いづらいよ。

int dy[] = { 0, 1, 0, -1 };
int dx[] = { 1, 0, -1, 0 };


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}

*/


/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/


/*実行開始からの経過時間を表すよ。

while (clock() < 1900000) {  }

*/


/*まだ使えないテクニックのメモだよ。

for (int bit = 0; bit < (1<<n); ++bit)//bit全探索用のfor文だよ

*/


/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; ++i) {
	for (int j = 0; j < w; ++j) {

	}
}

*/



int main() {
	int n;

	while (1) {
		cin >> n;
		if (n == 0) { break; }


		int a[105];
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		sort(a, a + n);
		int ans = 0;
		int k = 0;
		for (int i = 1; i < n - 1; i++) {
			ans += a[i];
			k++;
		}
		cout << ans / k << endl;
	}


	return 0;
}

C++: #include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
auto constexpr infty<int> = 1'100'100'100;
template<>
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

int main() {
  // cout << fixed << setprecision(10);

  int N;
  while (cin >> N && N) {
    vector<lli> scores;
    REP(i, N) {
      lli S; cin >> S;
      scores.push_back(S);
    }
    sort(begin(scores), end(scores));
    scores[0] = scores[N-1] = 0;
    cout << accumulate(begin(scores), end(scores), 0) / (N-2) << endl;
  }
  return 0;
}