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

int main(){
  int n, s, sum, max, min;
  while(1){
    cin >> n;
    if(n == 0) break;
    sum = 0;
    cin >> s;
    sum += s;
    max = s;
    cin >> s;
    sum += s;
    if(max < s){
      max = s;
    }else{
      min = s;
    }
    for(int i = 2; i < n; i++){
      cin >> s;
      sum += s;
      if(max < s){
	max = s;
      }else if(min > s){
	min = s;
      }
    }
    sum -= max;
    sum -= min;
    int ave = sum / (n-2);

    cout << ave << endl;
  }

  return 0;
}

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

int main(){
	int n, s, sum, maxs, mins, i;
	while((cin >> n), n){
		sum = maxs = 0;
		mins = 1000;
		for(i = 0; i < n; i++){
			cin >> s;
			sum += s;
			maxs = max(maxs, s);
			mins = min(mins, s);
		}
		sum = (sum - maxs - mins) / n;
		cout << sum << endl;
	}
}

C++: // ACM-ICPCà\I2007 A. ICPC ¾_Wv\tgEFA

#include <iostream>
#include <vector>

using namespace std;

int main(){
	int n;
	while(cin >> n, n){
		if(n==0) break;
		int m = 9999999, M = 0, sum = 0;
		for(int i=0;i<n;i++){
			int tmp; cin >> tmp;
			m = min(m,tmp);
			M = max(M,tmp);
			sum += tmp;
		}
		cout << (sum-m-M)/(n-2) << endl;
	}
}

C++: #include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<random>
#include<string>
typedef long long ll;
using namespace std;
int main(){
  ll N;
  ll s[1100];
  ll sum=0;
  ll t=0;
  while(t<=20){
  t++;
  cin >> N;
  for(ll i = 0; i < N; ++i){
      cin >> s[i];
  }
  sort(s,s+N);
  for(ll i = 1; i < N-1; ++i){
    sum+=s[i];
  }
  cout<<sum/(N-2)<<endl;
}
}

C++: 
#include<cstdio>
#include<iostream>
#include<string>
#include <algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
using namespace std;
using ll = long long;



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

}

C++: #include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
bool b[33000];
int main() {	
	int n;
	while (cin >> n&&n) {
		int a=10000000, b=-100,x;
		long long sum = 0;
		for (int i = 0; i < n; i++) {
			cin >> x;
			sum += x;
			a = min(a, x);
			b = max(b, x);
		}
		sum -= a;
		sum -= b;
		double c = floor((double)sum / (double)n - 2);
		cout << c << endl;
	}
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int s, n = 0;
    int mx = 0, mn = 0, sum = 0;
    while (1)
    {
        cin >> n;
        mx = -1;
        mn = 1001;
        sum = 0;
        if (n == 0)
            return 0;
        REP(i, n)
        {
            cin >> s;
            mx = max(mx, s);
            mn = min(mn, s);
            sum += s;
        }
        cout << (sum - mx - mn) / (n - 2) << endl;
    }
}

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

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

using namespace std;

int main() {
  int n;
  vector<int> r;

  while (true) {
    cin >> n;
    if (n == 0) break;
    int sum = 0;
    int max = -1;
    int min = 1001;
    REP(i, n) {
      int val;
      cin >> val;
      if (val > max) max = val;
      if (min > val) min = val;
      sum += val;
    }
    sum = sum - max - min;
    r.push_back((int)(sum / (n - 2)));
  }
  REP(i, r.size()) { cout << r[i] << endl; }
  return 0;
}

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

int main() {
	int n;
	while (cin >> n) {
		if (n == 0)break;
		int a[n];
		int ans = 0;
		for (int i = 0;i < n;i++) {
			cin >> a[i];
			ans += a[i];
		}
		sort(a, a + n);
		ans -= a[0] + a[n - 1];
		ans /= n - 2;
		cout << ans << endl;
	}
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main() {
    int n=100,input=100;
    while (1){
        scanf("%d", &n);
        if (n==0){
            break;
        }
        int sum=0,max=0,min=1001;
        for (int i;i<n;i++) {
            cin >> input;
            sum = sum+input;
            if (max < input) max = input;
            if (min > input) min = input;
        }
        printf("%d\n", (sum-max-min)/(n-2));
    }
}

C++: #include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
  
int main()
{

	int sum=0;
	int n;
	int max;
	int min;
	int i;
	int m;


	while(1)
	{
	scanf("%d",&n);
	if(n==0)
		break;

	max=0;
	min=1000;
	sum=0;

	for(i=0;i<n;i++)
	{
		scanf("%d",&m);
		sum+=m;
		if(m>max)
			max=m;
		if(m<min)
			min=m;
	}

	sum = sum-max-min;

	printf("%d\n",(sum/(n-2)));
	}

	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cassert>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<utility>
using namespace std;


int n,s[200];

/*
input data
*/

void init(){
}

bool input(){
	cin>>n;
	if(n==0) return false;
	for(int i=0; i<n; i++) cin>>s[i];
	return true;
}


void swap(){
	int tmp;
	for(int i=0; i<n; i++){
		for(int j=n-1; j>i; j--){
			if(s[j-1]>s[j]){
				tmp=s[j-1];
				s[j-1]=s[j];
				s[j]=tmp;
			}
		}
	}
}



int solve(){
	int sum=0, ans=0;
	swap();
	for(int i=1; i<n-1; i++){
		sum+=s[i];
	}
	ans=sum/(n-2);
	return ans;
}


int main(){
  while(input()){
    cout<<solve()<<endl;
  }
}

C++: #include <iostream>
#include <vector>
#include <numeric>
#include <climits>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm> 

/*
	メモ
	#inlucde <string>
	memset(配列,初期化値,sizeof(配列));//配列初期化

	#include <queue>
	push(),back(),front()
	pop()//最初の要素削除

	#inclue <stack>
	pop(),push(),top(),empty()

	__builtin_popcount(unsigned int);

*/

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{"; for(auto nth : list){ cout << nth << " ";}cout << "}" << endl;

using namespace std;

int main() {

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

		vector<int> list;
		rep(i,n){
			int tmp;
			cin >> tmp;
			list.push_back(tmp);	
		}
		sort(list.begin(),list.end());
		
		int ans=0;
		for(int k=1;k<list.size()-1;k++){
			ans+=list[k];
		}
		cout << ans/(list.size()-2) << endl;
	}
}