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 <algorithm>
using namespace std;

int main() {
    int n; cin >> n;
    while (n != 0) {
        int max_s = 0, min_s = 1000, sum_s = 0;
        for (int i = 0; i < n; ++i) {
            int s; cin >> s;
            max_s = max(max_s, s);
            min_s = min(min_s, s);
            sum_s += s;
        }
        int ans = (sum_s - max_s - min_s) / (n - 2);
        cout << ans << endl;
        
        cin >> n;
    }
    return 0;
}

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

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

int main() {
	while (cin >> N && N>0) { // By while (), adopt the form of std in 
		int sum = 0;
		max = 0;
		min = 0;
		for (int i=0; i<N; i++) {
			cin >> S;
			sum += S; // calculate sum
			if (max < S) max = S; // search max
			if (min > S) min = S; // search min
		}
		int ans = (sum-max-min)/(N-2);
		cout << ans << endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

const int MAX_N = 110;

int judge_num;
int score[MAX_N];

//---------------------//                                                                                            
int main()
{
        while (cin >> judge_num) {

                if (judge_num == 0) break;

                for(int i = 0; i < judge_num; ++i) {
                        cin >> score[i];
                }

                sort(score, score + judge_num);

                int ave;
                double sum_temp = 0;

                for (int i  = 1; i < judge_num - 1; ++i) {
                        sum_temp += score[i];
                }

                ave = (int)( floor( sum_temp / (judge_num - 2) ) );

                cout << ave << endl;
        }

        return 0;
}

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

int main() {
	int n,point,sum,ma,mi;
	
	while(cin>>n){
		if(n==0)break;
		sum=0;
		ma=0;
		mi=1000;
		for(int i=0;i<n;i++){
			cin>>point;
			sum+=point;
			if(ma<point)ma=point;
			if(mi>point)mi=point;
		}
		cout<<(sum-ma-mi)/(n-2)<<endl;;
			}
	
	
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265


void f(int n){

  int a[1000000];

  rep(i,n){
    cin>>a[i];
  }
  sort(a,a+n);

  int ans=0;
  FOR(i,1,n-1){
    ans+=a[i];
  }

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


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


  return 0;
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <tuple>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#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 SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    int sum=0,M=0,m=0;
    REP(i,n){
      int tmp;
      cin >> tmp;
      sum+=tmp;
      if(M<tmp) M=tmp;
      if(m>tmp) m=tmp;
    }
    cout << (sum-M-m)/(n-2) << endl;
  }
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int n;
int data[100];


int solve() {
  int avg;
  sort(data, data+n);
  avg = 0;
  for(int i = 1; i < n-1; ++i) {
    avg += data[i];
  }
  return avg / (n-2);
}

main() {
  while(( cin >> n ) && n) {
    for(int i = 0; i < n; ++i) {
      cin >> data[i];
    }
    cout << solve() << endl;
  }
}

C++: #include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        int sum = 0, MAX = 0, MIN = 1100;
        rep(i, 0, n){
            int s;
            cin >> s;
            sum += s;
            MAX = max(MAX, s);
            MIN = min(MIN, s);
        }
        cout << (sum - MAX - MIN) / (n - 2) << endl;
    }
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

signed main() {
	while (true) {
		int n;
		cin >> n;

		if (n == 0) break;

		vector<int> s;
		inputVector(s, n);

		sort(all(s));

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

    return 0;
}