Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for {
		num := nextInt(sc)
		if num == 0 {
			break
		}

		score_list := []int{}
		for i := 0; i < num; 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))
	}
}

C++: #include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
using namespace std;

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

typedef long long ll;

int main(void) {
    int n;
    while (cin>>n && n){
        int sum=0 , h=0 , l=1000;
        REP(i,n){
            int s;
            cin >> s;
            sum+=s;
            h = max(h,s);
            l = min(l,s);
        }
        sum -= h+l;
        cout << sum/(n-2) << endl;
    }
    
    return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define PII pair<int,int>
#define PCC pair<char,char>
#define PCI pair<char,int>
#define PIC pair<int,char>
#define MP make_pair
#define DEBUG(x) cout<<#x<<": "<<x<<endl;

int main()
{
	int n;
	for (; cin >> n, n != 0;)
	{
		int Min = INF;
		int Max = -1;
		int sum = 0;
		REP(i, n)
		{
			int temp;
			cin >> temp;
			Min = min(Min, temp);
			Max = max(Max, temp);
			sum += temp;
		}
		sum =sum - Min - Max;
		int ans = sum / (n-2);
		cout <<ans<< endl;
	}
	return 0;
}

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

int main()
{
int n;
vector<int> s;
scanf("%d", &n);
s.resize(n);
for(int i = 0; i < n; ++i)
scanf("%d", &s[i]);
sort(s.begin(), s.end());
int sum = 0;
for(int i = 1; i < n - 1; ++i)
sum += s[i];
printf("%d\n", sum / (n - 2));
return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
 
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}
void pv(vector<int>&v){
	for(int i = 0;i<v.size();i++){
		if(i)cout<<' ';
		cout<<v[i];
	}
	cout<<endl;
}



signed main()
{
	//IOS();
	int N;
	vector<int>ans;
	while(cin>>N){
		if(N==0)break;
		int ma = -INF,mi = INF,sum = 0;
		rep(i,0,N){
			int t;
			cin>>t;
			chmin(mi,t);
			chmax(ma,t);
			sum+=t;
		}
		ans.push_back((sum-mi-ma)/(N-2));
	}
	for(auto e:ans){
		cout<<e<<endl;
	}
}

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

int score(vector<int> v) {
	int len, sum;
	sort(v.begin(), v.end());
	len = v.size();
	sum = accumulate(v.begin(), v.end(), 0);
    cout << sum / len << endl;
}

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

	while (1) {
		cin >> n;
		if (n == 0) break;
		int tmp;
		for (int i = 0; i < n; i++) {
			cin >> tmp;
			v.push_back(tmp);
		}
        score(v);
	}

	return 0;
}

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

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

C++: #include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>

using namespace std;

int matrix[20][20];

int main()
{
    while(true)
    {
        int n;

        cin >> n;
        
        if(!n) break;

        vector<int> vec(n);

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

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

    return 0;
}

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

C++: #include<stdio.h>

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

  while (1) {
    scanf("%d", &n);
    if (n==0) {
      break;
    }
    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 <iostream>
#include <cmath>
using namespace std;

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

C++: #include <iostream>
using namespace std;
int larger(int x,int y) {
	int z = 0;
	if (x > y)z = x;
	else z = y;
	return z;
}
int smaller(int x, int y) {
	int z = 0;
	if (x < y)z = x;
	else z = y;
	return z;
}
int main(void) {
	int s = 1;
	while (s == 1) {
		int sinsa, a[100], sum = 0, ave;
		cin >> sinsa;
		if (sinsa == 0)s = 2;
		for (int i = 0; i < sinsa; i++) {
			cin >> a[i];
		}
		int n = a[0];
		for (int i = 0; i < sinsa; i++) {
			n = larger(n, a[i]);
		}
		int m = a[0];
		for (int i = 0; i < sinsa; i++) {
			m = smaller(m, a[i]);
		}
		for (int i = 0; i < sinsa; i++) {
			sum += a[i];
		}
		sum = sum - n - m;
		ave = sum / (sinsa - 2);
		cout << ave;
	}

	return 0;

}

C++: #include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<cassert>

#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(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> ans = vector<int>(n,0);
		rep(i,n){
			cin >> ans[i];
		}
		
		sort(ans.begin(),ans.end());
		
		int sum=0;
		for(int i=1;i<n-1;i++){
			sum+=ans[i];
		}
	
		cout << sum/(n-2) << endl;

	}


	return 0;
}