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 <bits/stdc++.h>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#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 range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 24;

int main(void){
    for(int n; cin >> n, n;){
        vi s(n); for(auto && ss : s) cin >> ss;

        sort(all(s));

        int res = 0;
        range(i, 1, n - 1) res += s[i];

        cout << res / (n - 2) << endl;
    }

	return 0;
}

C++: #include<stdio.h>
int main(){
  int n,a[100],i,max=0,min=1000,c;
  while(1){
    c=0;
    max=0;
    min=1000;
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<n;i++){
      scanf("%d",&a[i]);
      if(max<a[i])max=a[i];
      if(min>a[i])min=a[i];
    }
    for(i=0;i<n;i++){
      c+=a[i];
    }
    c-=max+min;
    printf("%d\n",c/(n-2));
  }
  return 0;
}

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

int main(){

	int n;
	while(cin >> n, n){
		vector<int> score;
		for(int i=0; i<n; i++){
			int s; cin >> s;
			score.push_back(s);
		}
		sort(score.begin(), score.end());
		int sum = accumulate(score.begin(), score.end(),0);
		cout << ( sum - score.back() - score.front() )/ (score.size()-2) << endl;
	}

	return 0;
}

C++: #include<stdio.h>
int main(){
  int n,sum=0,s,i,mx=0,mn=1000;
  int av;
  while(scanf("%d",&n)&&n!=0){
    n,s,i,sum=0,mx=0,mn=1000;   
    for(i=0;i<n;i++){
      scanf("%d",&s);
      sum+=s;
      if(mx<s)
	mx=s;
      if(mn>s)
	mn=s; 
    }
    sum=sum-(mn+mx);
    av=sum/(n-2);
    printf("%d\n",av);
  }
  
  return 0;
}

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;
  while(N){
  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;
  cin>>N;
}
}

C++: #include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    while(true) {
        int n; cin >> n;
        if (n == 0) break;
        vector<int> v(n);
        REP(i,n) cin >> v[i];
        sort(ALL(v));
        int ans = accumulate(ALL(v),0) - v.front() - v.back();
        ans /= v.size() -2;
        cout << ans << endl;
    }

    return 0;
}

C++: #include <stdio.h>

int main( void ) {

	int n, i, s[100], max = 0, min = 1000, sum = 0;

	while ( scanf( "%d", &n ) && n > 0 ) {

		for ( i = 0; i < n; i++ ) {

			scanf( "%d", &s[i] );

			if ( s[i] > max ) { max = s[i]; }
			if ( s[i] < min ) { min = s[i]; }

			sum += s[i];

		}

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

	}

	return 0;

}

C++: #include <stdio.h>

int main(){
    int n,s[100]={0};
	int max,min,max1,min1;
	int sum,i;

//scanf("%d",&n);

while(scanf("%d",&n)!=0) {
	max=0;
    printf("%d\n",scanf("%d",&n));
	min=100000;
	sum=0;
	sum=0;
    max1=0;
    min1=0;
	for (i=0;i<n;i++){
		scanf("%d",&s[i]);
		if(s[i]>max){
            max=s[i];
			max1=i;
		}
		if(s[i]<min){
			min=s[i];
            min1=i;
		}
	}
	for(i=0;i<n;i++){
		if(i!=max1&&i!=min1){
			sum+=s[i];
		}
	}
	printf("%d\n",sum/(n-2));
	//scanf("%d",&n);
}//while (n!=0);
return 0;
}

C++: #include<iostream>
#include<list>
#include<string>
#include<algorithm>
#include <utility>
#include<stdio.h>
#include<climits>
#include <vector>
#include <queue>

using namespace std;

int main(void){
    int n;
    int i,j;
    int min,max,s;
    while(1){
        cin >> n;
        if(!n) break;
        s = 0;
        cin >> j;
        min = max = j;
        s += j;
        for(i = 1;i < n;i++){
            cin >> j;
            if(min > j) min = j;
            if(max < j) max = j;
            s += j;
        }
        cout << (s-min-max)/(n-2) << endl;
    }
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, num[110];

int main(){
	while (cin >> n&&n){
		REP(i, 110)num[i] = 0;
		int sum = 0;
		REP(i, n){
			cin >> num[i];
			sum += num[i];
		}
		sort(num, num + n);
		sum -= num[0] + num[n - 1];
		cout << sum / (n - 2) << endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;

//constant
const int inf=1<<28;

//variable
int n;
int in;
int maxi=-inf;
int mini=inf;
int sum;


int main(){

    while(cin>>n, n){
        sum=0;
        maxi=-inf;
        mini=inf;
        for(int i=0; i<n; i++){
            cin>>in;
            maxi=max(in,maxi);
            mini=min(in,mini);
            sum+=in;
        }
        //out<<maxi<<' '<<mini<<endl;
        cout<<(int)(((sum-maxi-mini)*1.0)/(n-2))<<endl;
    }

    return 0;
}

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

int main(void)
{
	int n, s;
	while (cin >> n, n){
		cin >> s;
		int ma, mi, sum;
		ma = mi = sum = s;
		
		for (int i = 1; i < n; i++){
			cin >> s;
			ma = max(s, ma);
			mi = min(s, mi);
			sum += s;
		}
		n -= 2;
		sum -= (ma + mi);
		
		int res = sum / n;
		
		cout << res << endl;
		
	}
	
	return 0;
}

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

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

int n, score[100];

void solve() {
  rep(i,n) cin>>score[i];

  sort(score, score+n);
  double sum = 0;
  REP(i,1,n-1) sum += score[i];
  
  cout<<(int)(sum/(n-2))<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>n, n) {
    solve();
  }
  return 0;
}