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 <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;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
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 main(){

  int n;

  int tensu[200];

  while(cin>>n,n){
	cout << n << endl;//
  int max = 0;
  int min = 1000;
  int sum=0;
	REP(i,n){
	  cin >> tensu[n];
	  sum+=tensu[n];
	  if(max<tensu[n])
		max=tensu[n];
	  if(min>tensu[n])
		min=tensu[n];
	}

	//cout<<min<<endl<<max<<endl<<sum<<endl;//

	cout << (sum-max-min)/(n-2) << endl;

  }

}