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 <algorithm>
using namespace std;
int main()
{
	int n, p[100], i, s;
	while (cin >> n && n)
	{
		for (i = 0; i < n; i++)
			cin >> p[i];
		sort(p, p+n);
		for (i = 1, s = 0; i < n-1; i++)
			s += p[i];
		cout << s / (n-2) << endl;
	}
}

C++: #include <algorithm>
#include <cstdio>
#include <numeric>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;

int main() {
    while (true) {
        int n; scanf("%d", &n);
        if (n == 0) break;
        vector<int> a(n); repeat (i, n) scanf("%d", &a[i]);
        whole(sort, a);
        int result = (whole(accumulate, a, 0) - a.front() - a.back()) / (n - 2);
        printf("%d\n", result);
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main()
{
	while (1) {
		cin >> n;
		if (n == 0) {
			return 0;
		} else {
			vi v(n);
			ans = 0;
			REP(i, n) cin >> v[i];
			sort(ALL(v));
			ans = accumulate(ALL(v), 0LL);
			ans -= (v[0] + v[n - 1]);
		}
		cout << ans / (n - 2) << endl;
	}
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){

  int sum = 0, x, total, ans;
  vector<int> p1(0);
  vector<int> p2(0);
  int n;
  
    while(1){
      cin >> n;
      if(n==0)
      break;
      for(int i=0; i<n; i++){
        cin >> x;
        p1.push_back(x);
      }

      int max = *max_element(p1.begin(), p1.end());
      int min = *min_element(p1.begin(), p1.end());

      for(int i=0; i<n; i++){
        sum += p1[i];
      }
      total = sum - min - max;
      ans = total / (n-2);
      cout << ans << endl;
      p1 = p2;
      sum = 0;
      total = 0;
      ans = 0;
    }

  return 0;
}

C++: #include <iostream>
#include <math.h>
using namespace std;
int main(){

	while (1){
		int n;
		int sum = 0;
		cin >> n;
		if (n == 0){
			return 0;
		}
		int s;
		int max = -1;
		int min = 9999;
		for (int i = 0; i < n; i++){
			cin >> s;
			sum += s;
			if (s > max){
				max = s;
			}else if (s < min){
				min = s;
			}
		}
		int ans = floor((sum - max - min) / (n - 2));
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
        int n;
        while(cin >> n, n) {
                vector<int> score;
                for(int i=0; i<n; i++) {
                        int k;
                        cin >> k;
                        score.push_back(k);
                }
                sort( score.begin(), score.end() );
                int res = 0;
                for(int i=1; i<n-1; i++) {
                        res += score[i];
                }
                cout << res/(n-2) << endl;
        }
        return 0;
}

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

int main() {
  int n;
  while (cin >> n, n) {
    auto v = vector<int>(n);
    for (int i = 0; i < n; ++i) cin >> v[i];
    sort(begin(v), end(v));
    int s = accumulate(begin(v) + 1, end(v) - 1, 0);
    cout << s / (n - 2) << endl;
  }
  return 0;
}

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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define INF INT_MAX/2

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

		int sum = 0;
		int _max = -1;
		int _min = INF;
		rep(i, 0, n)
		{
			int s; cin >> s;
			sum += s;
			_max = max(_max, s);
			_min = min(_min, s);
		}
		sum -= _max;
		sum -= _min;
		cout << sum / (n - 2) << endl;
	}
}

C++: #include<stdio.h>

int main(){
	int loop = 0;
	int i,buf;
	while(true){
		scanf("%d",&loop);
		if(loop == 0){
			break;
		}
		int max = -1;
		int min = 1000;
		int ans = 0;
		for(i=0;i<loop;i++){
			scanf("%d",&buf);
			if(max < buf){
				max = buf;
			}
			if(min > buf){
				min = buf;
			}
			ans += buf;
		}
		ans -= (max + min);
		printf("%d\n",ans/(loop-2));
	}
}

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

int main(){
  int flag = 1;
  int n,x;
  cin >> n;
  if(n==0) return 0;
  while(flag){
    int max = -1;
    int min = 1001;
    int sum = 0;
    for(int i=0;i<n;i++){
      cin >> x;
      if(x >= max){
        sum += max;
        max = x;
      }else if(x <= min){
        sum += min;
        min = x;
      }else sum += x;
    }
    sum -= 1000;
    sum = sum / (n - 2);
    cout << sum << endl;
    cin >> n;
    if(n == 0) flag = 0;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-9;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    for(;;){
        int n;cin>>n;
        if(n==0)return 0;
        int a[n];
        rep(i,0,n)cin>>a[i];
        sort(a,a+n);
        int sum=0;
        rep(i,1,n-1)sum+=a[i];
        sum/=(n-2);
        cout<<sum<<endl;
    }
}