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 <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
    int n;
    while(cin>>n,n){
        vint v(n);
        rep(i,n) cin>>v[i];
        sort(ALL(v));
        ll sum = 0;
        reep(i,1,n-1){
            sum += v[i];
        }
        cout << sum/n-2 << endl;
    }
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

C++: int maximum = 0;
for (int i=1; i<S; ++i)
    for (int j=i; j<S; ++j)
        if (tax(X,i)+tax(X,j) == S) // (*)
            maximum = max(maximum, tax(Y,i)+tax(Y,j));

C++: #include <iostream>
using namespace std;
int n;
int main(){
	while(cin>>n&&n){
		int p;
		int pmax=-10000000,pmin=1000000;
		int sum=0;
		for(int i=0;i<n;i++){
			cin>>p;
			pmax=max(p,pmax);
			pmin=min(p,pmin);
			sum+=p;
		}
		cout<<(sum-(pmax+pmin))/(n-2)<<endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main()
{
        while(true)
        {
                int n,A[100]={0};
                cin>>n;
                if(n==0) break;
                rep(i,n) cin>>A[i];
                sort(A,A+n);

                int sum=0;
                rep(i,n-2) sum+=A[i+1];
                cout<<sum/(n-2)<<endl;
        }
        return 0;
}

C++: # encodign: utf-8

while true do
    # ????°??????§???????????? (?????????0??\???1000??\???)
    max = -1
    min = 1001
    # ????¨?????????????
    sum = 0
    # n??????
    n = gets.to_i
    break if n == 0 # 0?????¨????????????
    # n?????????????????????
    n.times do
        v = gets.to_i
        min = v if v < min
        max = v if v > max
        sum += v
    end
    sum -= (min + max)
    p sum / (n-2)
end

C++: #include<iostream>

using namespace std;

int main () {

  while (true){

    int n;
    int i;
    int s = 0;
    int mi = 0;
    int ma = 0;
    cin >> n;

    if (n == 0)
      break;
??????
??????int p[100];

    for (i=0,i<n,i++){
      cin >> p[i];

      if (p[i] < mi)
        mi << p[i];

      if (p[i] > ma)
        ma << p[i];

      s += p[i];

    }

    cout << (s - mi - ma) / (n-2)

  }

  return 0;

}

C++: #include "bits/stdc++.h"
using namespace std;
#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
typedef long long ll;

const int INF = 1e9 + 7;
const long long LLINF = 1e18;

ll n;
int main() {
    while(cin>>n, n!=0){
        ll s;
        ll mx=-LLINF, mn=LLINF, sum=0;
        REP(i, 0, n){
            cin>>s;
            mx=max(mx, s);
            mn=min(mn, s);
            sum+=s;
        }

        cout<<(sum-mx-mn)/(n-2)<<endl;
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
	int max,min,sum,ans,n;
	int s[101];

	while(1){
		//ÏÌú»
		max = 0;
		min = 1001;
		sum = 0;
		
		//f[^ZbgnÌüÍ
		cin >> n;
		if(n==0) break;//0 0ªüÍ³ê½çI¹

		//f[^ZbgÌ¾¯_ðüÍ
		for(int i=0 ; i<n ; i++){
			cin >> s[i];
		}
		//ÅålAÅ¬lÌlðÛ·é
		for(int i=0 ; i<n ; i++){
			if(max<s[i]) max = s[i];
			if(min>s[i]) min = s[i];
		}
		//ÅåÌ_ðÐÆÂr·é(0ðüêé)
		for(int i=0 ; i<n ; i++){
			if(max==s[i]){
				s[i]=0;
				break;
			}
		}
		//Å¬Ì_ðÐÆÂr·é(0ðüêé)
		for(int i=0 ; i<n ; i++){
			if(min==s[i]){
				s[i]=0;
				break;
			}
		}
		//_Ìvðßé
		for(int i=0 ; i<n ; i++){
			sum += s[i];
		}
		//_Ìv©ç½Ïðßé
		ans = sum/(n-2);
		//¦ÌoÍ
		cout << ans << endl;
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  while(true){
    int n;
    int sum=0;
    int mx=0;
    int mn=1001;
    cin >>n;
    if(n==0)break;
    for(int i =0;i<n;++i){
      int t;
      cin >> t;
      sum += t;
      mx = max(t,mx);
      mn = min(t,mn);
    }
    sum = (sum-mx-mn) / (n-2);
    cout << sum << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>

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

using namespace std;

int main(){
    vector<int> vc;
    int n;
    while(cin >> n){
        if(n == 0) break;
        int tmp;
        vc.clear();
        REP(i,n){
            cin >> tmp;
            vc.push_back(tmp);
        }
        sort(vc.begin(), vc.end());
        vc.erase(vc.begin());
        vc.erase(--vc.end());
        int sum = 0;
        vector<int>::iterator it = vc.begin();
        while(it != vc.end()){
            sum += (*it);
            it++;
        }
        cout << sum/(n-2) << endl;
    }
    return 0;
}