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>
using namespace std;
int N,S;

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

C++: #include <iostream>
using namespace std;
int N,S;
int set = 0;
int main(){
  while(set <= 20){
    //while(cin >> N && N >= 3 && N <= 100) {
    cin >> N;
    if (N == 0) break;
    int largest = 0;
    int smallest = 1000;
    int sum = 0;
    for (int i = 0; i <N;++i) {
      cin >> S;
      if(largest < S) largest = S;
      if(smallest >S) smallest = S;
      sum += S;
    }
    cout << (sum - largest - smallest)/(N-2) << endl; 
  ++set;
  }
  return 0;
}

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

using namespace std;
int N, S;
int main() {
  while (cin >> N && N > 0) {
    int sum = 0;
    int m = 1001;
    int M = -1;
    for (int i = 0; i < N; ++i) {
      cin >> S;
      sum += S;
      m = min(m, S);
      M = max(M, S);
    }
    sum = sum - m - M;
    int ans = sum / (N-2);
     cout << ans << endl;
  }
  return 0;
}

C++: #include<cstdio>

bool solve(){
	int n,ma = 0,mi = 1000,sum = 0;
	scanf("%d",&n);
	if(n==0) return false;
	for(int i=0;i<n;i++){
		int s;
		scanf("%d",&s);
		if(s<mi) mi = s;
		if(s>ma) ma = s;
		sum += s;
	}
	printf("%d\n",(sum-ma-mi)/(n-2));
	return true;
}

int main(){
	while(solve()){}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n, s, maxn, minn;

  while(1){
    scanf("%d", &n);
    if(n==0) break;

    maxn=0;
    minn=1000;
    int x=0;
    for(int i=0;i<n;i++){
      scanf("%d", &s);
      x+=s;
      maxn=max(s,maxn);
      minn=min(s,minn);
    }

    printf("%d\n",(x-maxn-minn)/(n-2) );
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int judge;
int maxscore =0;
int minscore =0;
int maxnum;
int minnum;
cin >> judge;
int score[judge];
	for(int i=0; i<=judge; i++){
	cin >> score[i];
		if(score[i] > maxscore){
		maxscore = score[i];
		i=maxnum;
		}
		if(score[i] < minscore){
		minscore = score[i];
		i = minnum;
		}
	}
score[maxnum] = 0;
score[minnum] = 0;
int lastscore = 0;
for(int j=0;j<=judge;j++){
lastscore += score[j];
}
lastscore = lastscore/(judge - 2);
cout << lastscore <<endl;
return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int main(void){
	int32 n;
	while(cin >> n && n){
		vector<int32> x(n);
		int32 sum = 0;
		REP(i, n){
			cin >> x[i];
			sum += x[i];
		}
		cout << (sum-*(max_element(all(x)))-*min_element(all(x)))/(n-2) << endl;
	}
}

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

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

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

C++: while true do
    max = -1
    min = 1001
    sum = 0
    n = gets.to_i
    break if n == 0
    n.times do
        v = gets.to_i
        min = v if v < min
        max = v if v > max
        sum += v
    end
    sum -= (min + max)
    p sum / (n-2)
end

C++: #include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll INF=1000000000LL;
const ll MOD=1000000007LL;
const ll MAX=100010;
int main(){
	int n;
	while(cin>>n,n){
		int ma=0;
		int mi=INF;
		int sum=0;
		for(int i=0;i<n;i++){
			int s;
			cin>>s;
			sum+=s;
			ma=max(s,ma);
			mi=min(s,mi);
		}
		cout<<(sum-ma-mi)/(n-2)<<endl;
	}
	return 0;
}

C++: #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

#define Rep(b, e, i) for (int i = b; i <= e; i++)
#define Repr(e, b, i) for (int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n - 1, i)
#define repr(n, i) Repr(n - 1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)), (x).end())

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1 <<29;
const int MOD = 1000000007;

void solve(void) {
  while (1) {
    int N;
    scanf("%d\n", &N);
    if (N == 0) break;
    vector<int> ps;
    rep(N, i) {
      int p;
      scanf("%d\n", &p);
      ps.pb(p);
    }
    sort(all(ps));
    int ans = - ps[0] - ps[N-1];
    for (int t : ps)  ans += t;
    printf("%d\n", ans / (N-2));
  }
}

int main(void) {
  solve();
  return 0;
}