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 <fstream>
using namespace std;

int main(){
int raw,j,a[100];
while (1) {
	//cout << "????????°?????\???" << endl;
	cin >> raw;
	if (raw == 0) { break;
	}
	else {
		//cout << "?????????????§?" << endl;

		for (j = 0; j < raw; j++) { cin >> a[j]; }
		int min = a[0], max = a[0];
		for (j = 0; j < raw; j++) {
			if (a[j] < min) { min = a[j]; }	
		if (a[j] > max) { max = a[j]; }
	}
	int sum = 0;
	for (j = 0; j < raw; j++) { sum = sum+a[j]; }
	cout << (sum - min - max) / (raw - 2)<<endl;
	}
}
return 0;}

C++: #include<stdio.h>

int main(){
  int i, n, s;
  int ans = 0, maxv = 0, minv = 1000;

  scanf("%d", &n);

  int score[n];
  for (i = 0; i < n; i++) {
    scanf("%d", &s);
    if (s > maxv) {
      maxv = s;
    }
    if (s < minv) {
      minv = s;
    }

    score[i] = s;
  }

  for (i = 0; i < n; i++) {
    ans += score[i];
  }

  printf("%d\n", (ans-maxv-minv)/(n-2));
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main(void)
{

  while(1){
    int n; cin >> n;

    vector<int> array(n, 0);
    if(n == 0) break;

    int sum = 0;
    for(int i = 0; i < n; i++){
      int input; cin >> input;
      array[i] = input;
    }
   
    sort(array.begin(), array.end() );

   
    for(int i = 1; i < n-1; i++){
      sum += array[i];
    }
    cout << sum/(n - 2)<< endl;
  }
  return 0;
}

C++: #include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
    int n, t, sum, minv, maxv;
    for (; ;) {
        scanf("%d", &n);
        if (n == 0) break;
        sum = maxv = 0, minv = 1001;
        for (int i = 0; i < n; i++) {
            scanf("%d", &t);
            sum+=t;
            maxv = max(maxv, t);
            minv = min(minv, t);
        }
        printf("%d\n", (sum-maxv-minv)/(n-2));
    }
    return 0;
}

C++: #include <stdio.h>
#include <algorithm>

int main(void)
{
    while(true) {
        int M=0,m=50000,n,sum=0;
        scanf("%d", &n);
        if(n==0) break;
        for(int i=0; i < n; i++)
        {
            int s;
            scanf("%d", &s);
            M = std::max(s, M);
            m = std::min(s, m);
            sum += s;
        }
        printf("%d\n", (sum-M-m)/(n-2));
    }

    return 0;

}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	while(1){
		int n;
		vector<int> p;
		cin>>n;
		if(n==0) break;
		for(int i=0;i<n;i++){
			int score;
			cin>>score;
			p.push_back(score);
		}
		sort(p.begin(),p.end());
		int sum=0;
		for(int j=1;j<n-1;j++){
			sum += p[j];
		}
		double ave=sum/(n-2);
		cout<<(int)ave<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int n;
	int avg=0;
	int s[100];
	while (true){
		std::cin >> n;
		if (n == 0) break;
		int q = n - 2;
		for (int i = 0; i < n; i++){
			std::cin >> s[i];
		}
		std::sort(s, s + n);
		for (int i = 1; i <= n-2; i++){
			avg += s[i];
		}
		std::cout << avg /q << "\n";
		avg = 0;
		for(int i = 0; i < n; i++){
			s[i]=0;
		}
	}
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a[101],sum,n;
	while(cin>>n,n){
	sum=0;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<n;i++)cout<<a[i]<<" ";
	for(int i=0;i<n;i++)if(i!=0&&i!=n-1)sum+=a[i];
	cout<<"sum"<<sum;
	cout<<sum/(n-2)<<endl;
	}
	return 0;
}

C++: //a
#include <iostream>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <functional>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>

#define REP(i,b,n) for(int i=b;i<n;i++)
#define REPR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PB push_back
#define MP make_pair

using namespace std;

static const double PI = acos(-1.0);
static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> pii;

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

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	int x[1000] = { 0 };
	int y[20] = { 0 };
	int max;
	int min;
	n = 1;
		int j = 0;
		while (n != 0){
			
			cin >> n;
			max = 0;
			min = 1000;
				y[j] = 0;
			for (int i = 0; i < n; i++){
				cin >> x[i];
				if (max < x[i]) max = x[i];
				if (min > x[i]) min = x[i];
				y[j] += x[i];
			}
			y[j] = y[j]-max - min;
			y[j] = y[j] / (n - 2);
			j++;
		}
	for (int k = 0; k < j; k++){
		cout << y[k]<< endl ;
	}
	return 0;
}

C++: #include <iostream>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <bitset>

using namespace std;

int main(void)
{
  while (true) {

    int n;
    cin >> n;
    if (n == 0) break;
    int p[n];
    for (int i = 0; i < n; i++)
      cin >> p[i];
    int top,bottom,sum;
    top = -1;
    bottom = 1001;
    sum = 0;
    for (int i = 0; i < n; i++) {
      if (top < p[i])
	top = p[i];
      if (bottom > p[i])
	bottom = p[i];
    }
    //cout << top << "  " << bottom << endl;
    
    bool t, b;
    t = b = true;
    for (int i = 0; i < n; i++) {
      if (top == p[i] && t) {
	t = false;
      }
      else if (bottom == p[i] && b) {
	b = false;
      }
      else
	sum+=p[i];
    }
    cout << (int)(sum/(n-2)) << endl;
    
  }
  return 0;	
}

C++: #include <stdio.h>
#include <bits/stdc++.h>

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N;
  cin>>N;
  while(N>0){
    vector<ll> v(N);
    FOR(i,0,N){
      cin>>v[i];
    }
    sortAl(v);
    ll res=0;
    FOR(i,1,N-1){
      res+=v[i];
    }
    cout<<res/(N-2)<<endl;
    cin>>N;
  }
}