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<cstdio>
#include<algorithm>
#include<vector>


using namespace std;

int main(void){


    int n;
    int s[128];
    while(scanf("%d", &n), n){
        int maxi = 0;
        int mini = 1000000000;
        int total=0, ns=0;

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

        for(int i = 0; i < n; i++){
            if(maxi == s[i]){
                maxi = -1;
                continue;
            }
            if(mini == s[i]){
                mini = -1;
                continue;
            }
            total += s[i];
            ns++;
        }
        printf("%d\n", total/ns);
    }



    return 0;
}

C++: #include<cstdio>
#include<cstdlib>
using namespace std;
#define MAX_N 100
int  n, i, judge[MAX_N], ans;

int sort(const void *a, const void *b){
  return *(int*)a - *(int*)b;
}

int main(){
  while(1){
    scanf("%d", &n);
    if(n == 0) break;
    for(i = 0; i < n; i++) scanf("%d", &judge[i]);
    qsort(judge, n, sizeof(int), sort);
    ans = 0;
    for(i = 1; i < n - 1; i++) ans += judge[i];
    printf("%d\n", ans / (n - 2));
  }
  return 0;
}

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

int main(){
	
	while(true){
		int n;
		cin >> n;
		if(n==0) break;
		int max=0,min=1000,sum=0;
		for(int i=0;i<n;i++){
			int a;
			cin >> a;
			sum+=a;
			if(max<a) max=a;
			if(min>a) min = a;
		}
		int result = (sum-max-min) / (n-2);
		cout << result << endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
  int n; //l
  int point[20], average;
  
  while(1){
    for(int i = 0 ; i < 20 ; i++){
      point[i] = 0;
    }
    average = 0;
    cin >> n;
    if(n == 0) break;

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

C++: #include<stdio.h>
#include<algorithm>
using namespace std;
int n, w[110], s;
int main(){
    int i;
    while(1){
        scanf("%d",&n);
        if(!n)break;
        for(i=1;i<=n;i++)scanf("%d",&w[i]);
        sort(w+1,w+n+1);
        s=0;
        for(i=2;i<n;i++)s+=w[i];
        s/=(n-2);
        printf("%d\n",s);
    }
}

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

int n,s[100];
int temp,ave,sum;

void sort(void){
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      if(s[i]>s[j]){
	temp=s[i];
	s[i]=s[j];
	s[j]=temp;
      }
    }
  }
}

int main(){
  while(cin >> n,n){
    for(int i=0;i<n;i++)
      cin >> s[i];  
    
    sort();
    
    sum=0;

    for(int i=0;i<n-2;i++)
      sum+=s[i+1];

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

C++: #include <iostream>
using namespace std;
int N,S;

int main() {
  while (cin >> N && N > 0) {
    int sum = 0, M = 0, m = 1e9;
    for (int i = 0; i < N; i++) {
      cin >> S;
      sum += S;
      if (M < S) M = S;
      if (m > S) m = S;
    }
    cout << (sum - M - m)/(N-2) << endl;
  }
}

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

int main(void)
{
    int sum, n, mmin, mmax, a;
    while(1) {
        sum = 0; mmax = -1; mmin = 114514810;
        cin >> n;
        if(n == 0) break;
        
        for(int i=0; i<n; i++) {
            cin >> a;
            sum += a;
            mmax = max(mmax, a);
            mmin = min(mmin, a);
        }
        sum = sum - mmax - mmin;
        cout << sum / (n-2) << endl;
    }
    
    return 0;
}

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

C++: #include<utility>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<deque>
#include<stack>
#include<complex>
#include<cmath>
#include<iostream>
#include<set>
#include<map>
#include<sstream>
#include<fstream>
#include<climits>
#include<chrono>
#include<random>
#include<functional>
#include<regex>

using namespace std;
typedef pair<int, int> P;
typedef long long ll;

// ??§????????°INF
const int INF = (1 << 30);
// ?¨±?????????????????
const double EPS = (1e-10);
// 2??????????????????????????????????????????
#define EQ(a,b) (abs((a)-(b)) < EPS)


int main()
{
	int n;
	while (true) {
		cin >> n;
		if (n == 0)break;
		vector<int> judges(n);
		int total = 0;
		for (int i = 0; i < n; ++i) {
			cin >> judges[i];
			total += judges[i];
		}
		int M = *max_element(judges.begin(), judges.end()),m=*min_element(judges.begin(),judges.end());
		total -= (M + m);
		int ans = total / (n - 2);
		cout << ans << endl;
	}
}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <climits>
using namespace std;

void solve(vector<int>& point)
{
	int total = point[0];
	int maxPoint = point[0];
	int minPoint = point[0];
	for(unsigned i=1; i<point.size(); ++i){
		total += point[i];
		maxPoint = max(maxPoint, point[i]);
		minPoint = min(minPoint, point[i]);
	}
	cout << ((total-maxPoint-minPoint)/(point.size()-2)) << endl;
}

int main()
{
	int number = 0;
	for(;;){
		int n;
		cin >> n;
		if(n == 0)
			break;

		vector<int> point(n);
		for(int i=0; i<n; ++i)
			cin >> point[i];

		solve(point);
	}

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
int a[110];

int main(){
	while(1){
		cin>>n;
		if(n==0)break;
		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)<<endl;
	}
}