Go: package main

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

var (
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	for sc.Scan() {
		n, _ := strconv.Atoi(sc.Text())
		scores := make([]int, n, n)
		for i := 0; i < n; i++ {
			sc.Scan()
			scores[i], _ = strconv.Atoi(sc.Text())
		}
		sort.IntSlice(scores).Sort()
		var sum = 0
		for i := 1; i < n-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
ll MIN(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}//pは素数,aのb乗をpで割った余り
ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}//pは素数,(nCr)%p
ll gcd(ll a, ll b) {

	if (a < b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	if (a%b == 0)return b;
	return gcd(b, a%b);

}//最大公約数
ll lcm(ll a, ll b) {

	return a / gcd(a, b)*b;

}//最小公倍数

int main() {
	
	while(1){
		int N;
		ll sum=0;
		cin>>N;
		if(N==0)break;
		vector<int> S;
		for(int i=0;i<N;i++){
			int s;
			cin>>s;
			S.pb(s);
			sum+=s;
		}
		sort(S.begin(),S.end());
		cout<<(sum-S[0]-S[N-1])/(N-2)<<endl;
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int n;
    int a[100];
    cin>>n;
    while(n!=0){
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        sort(a,a+n);
        int sum;
        for(int i=1;i<n-1;i++){
            sum+=a[i];
        }
        cout<<sum/(n-2)<<endl;
        cin>>n;
    }
}

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

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

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;



int main() {
	cout << fixed << setprecision(18);
	long long int n,x[120]={},mymin=INF,mymax=-INF,sum=0;
	cin>>n;
	while(n!=0){
		mymin=INF;mymax=-INF,sum=0;
		for(int i=0;i<n;i++){
			cin>>x[i];
			mymin=min(mymin,x[i]);
			mymax=max(mymax,x[i]);
			sum+=x[i];
		}
		cout<<(sum-mymax-mymin)/(n-2)<<endl;
		cin>>n;
	}
}

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

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

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

		sort(a.begin(),a.end());
		for (int i = 1; i < n-1; i++) sum += a[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 <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main() {
  int n;
  while (cin >> n && n) {
    vector<int> s;
    for (int i = 0; i < n; i++) {
      int tmp;
      cin >> tmp;
      s.push_back(tmp);
    }
    sort(s.begin(), s.end());
    int ans = accumulate(s.begin() + 1, s.end() - 1, 0) / (n - 2);
    cout << ans << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> p;
#define le 1000000007;
int main(){
  while(1==1){
  int n;
  cin >> n;
  if(n==0)break;
  long long int sum=0;
  vector<int> v(n,0);
  for(int i=0;i<n;i++){
    cin >> v[i];
    sum+=v[i];
  }
  cout << (sum-max(v[0],v[n-1])-min(v[0],v[n-1]))/(n-2) << endl;
  }
  return 0;
}

C++: # coding: utf-8

import sys

if __name__ == '__main__':
    while 1:
        n = int(input())
        if n == 0:
            break
        a = [int(input()) for i in range(n)]
        print((sum(a) - min(a) - max(a)) // (n-2));

C++: #include <iostream>
using namespace std;
int main(){
  int a[2020];
  int x,i = 0;
  while (cin >> x){
    a[i++] = x;
  }
  void saiten(int* a,int b);
  saiten(a,0);
}
void saiten(int* a,int j){
  int max = 0, min = 0, ave = 0;
  if (a[j] != 0){
    for (int k = j+1; k <= j+a[j]; k++){
      if (max < a[k])
	max = a[k];
      if (min > a[k])
	min = a[k];
      ave += a[k];
    }
    ave = (ave - max - min)/(a[j]-2);
    cout << ave << endl;
    saiten(a, j+a[j]+1);
  }
}

C++: #include <iostream>
using namespace std;
int max(int a, int b) {
	if (b < a) {
		b = a;
	}
	return b;
}
int min(int a, int b) {
	if (b > a) {
		b=a;
	}
	return b;
}
int main() {
	int s, n, t, sum=0, ave, maxi=0, mini=1000;
	while (1) {
		cin >> n;
		if (n == 0)break;
		for (t = 0; t < n; t++) {
			cin >> s;
			sum = sum + s;
			maxi = max(s,maxi);
			mini = min(s,mini);
		}
		sum = sum - maxi - mini;
		ave = sum / (n-2);
		cout << ave << endl;
		maxi = max(0,0), mini = min(1000,1000),sum=0;
	}
	return 0;
}

C++: #include<bits/stdc++.h>

using namespace std;

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

    }


}

C++: /*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp*/

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;

    while (cin>>n && n>0){
        vector<int> s;

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

            cin>>tmp;
            s.push_back(tmp);
        }
        sort(s.begin(),s.end());
        cout<<accumulate(++s.begin(),--s.end(),0)/(n-2)<<endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> res;
    while(1){
        int n;
        deque<int> rec;
        cin >> n;
        if(n == 0) break;
        for(int i=0;i<n;i++){
            int tmp;
            cin >> tmp;
            rec.push_back(tmp);
        }
        sort(rec.begin(), rec.end());
        rec.pop_front();
        rec.pop_back();
        int ans = 0;
        for(int i=0;i<n-2;i++){
            ans += rec[i];
        }
        res.push_back(ans/(n-2));
    }
    for(int i=0;i<res.size();i++) cout << res[i] << endl;
    return 0;
}