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;

int main(){
  int n,score[100],i,sum,k=1;
  int max,min;

  while(k<=20){
    sum=0;
    max=0;
    min=1000;
    
    cin >> n;
    if(n==0)break;
    for(i=0;i<n;i++){
      cin >> score[i];
      if(max<score[i])max=score[i];
      if(score[i]<min)min=score[i];
      sum+=score[i];
    }
    sum-=(max+min);
    n-=2;
    cout<<(sum/n)<<endl;
    k++;
  }
  return 0;
}

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

int main()
{
  int n;
  while(cin >> n && n > 0)
    {
      int s[100];
      int max=-1, min=1001;
      int sum=0, ave=0;
      for(int i=0;i<n;i++)
	{
	  cin >> s[i];
	  sum += s[i];
	  if(s[i] > max)
	    max = s[i];
	  if(s[i] < min)
	    min = s[i];
	}
      sum -= (max + min);
      ave = sum/(n-2);
      cout << ave << endl;
    }
}

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

using namespace std;

int main() {
    int n, s;
    vector<int> v;

    while (true) {
        cin >> n;

        if (!n) { break; }

        // 全要素を削除
        v.clear();

        for (int i = 0; i < n; i++) {
            cin >> s;
            v.push_back(s);
        }

        int max_v = *max_element(v.begin(), v.end());
        int min_v = *min_element(v.begin(), v.end());
        int sum_v = accumulate(v.begin(), v.end(), 0);

        cout << (sum_v - max_v - min_v) / (n-2) << endl;
    }

    return 0;
}

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

int main()
{
	int n;
	int ary[100];
	while (cin >> n, n)
	{
		for (int i = 0; i < n; i++) cin >> ary[i];
		int Max = *max_element(ary, ary + n);
		int Min = *min_element(ary, ary + n);
		int Sum = accumulate(ary, ary + n, 0);
		cout << (Sum - Max - Min) / (n - 2) << endl;
	}

	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long long int llint;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int,int>
#define pl pair<ll,ll>
const long double PI = acos(-1);
const long long INF = 1e15;
const ll DEP = (1LL << 50);
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
template<class T> bool chmax(T& a,T b){ if(a < b) {a = b; return true;} return false;}
template<class T> bool chmin(T& a,T b){ if(a > b) {a = b; return true;} return false;}
template<typename T>
T GCD(T x,T y){
    return y ? GCD(y,x%y) : x;
}
template<typename T>
string toString( const T &a ){
    ostringstream oss;
    oss << a;
    return oss.str();
};


/* 
void toporogical_sort(){
    for(int i = 0; i < v; i++){
        if(!In[i].size()) Q.push(i);
    }
    while(!Q.empty()){
        int t = Q.front(); 
        Q.pop();
        ans.push_back(t);
        for(int i = 0; i < Out[t].size(); i++){
            int nx = Out[t][i];
            int size = In[nx].size();
            for(int j = 0; j < size; j++){
                if(In[nx][j] == t){
                    In[nx].erase(In[nx].begin()+j);
                    break;
                }
            }
            if(!In[nx].size()) Q.push(nx);
        }
    }
}
*/

int N; 
int main(){
    while(true){
        cin >> N;
        if(N == 0) break;
        int a, mn = MM,mx = 0,ans = 0;
        for(int i = 0; i < N; i++){
            cin >> a;
            mn = min(mn,a);
            mx = max(mx,a);
            ans += a;
        }
        ans -= (mn+mx);
        ans /= (N-2);
        //cout << "ans=";
        cout << ans << endl;
    }
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int main(){
    int n;
    while(cin>>n,n!=0){
        int a[n];
        rep(i,n)cin>>a[i];
        sort(a,a+n);
        ll sum=0;
        rep(i,n-2)sum+=a[i+1];
        cout<<sum/(n-2)<<endl;
    }
    return 0;
}

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

C++: #include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int a;
	while(scanf("%d",&a),a){
		int M=0;int m=9999;
		int sum=0;
		for(int i=0;i<a;i++){
			int b;scanf("%d",&b);M=max(M,b);m=min(m,b);sum+=b;
		}
		printf("%d\n",(sum-M-m)/(a-2));
	}
}

C++: #include <iostream>
using namespace std;
int N, A[1024],Max,Min,Sum;

int main(){
 while(cin >> N && N>0){
  for (int i=0; i<N; ++i)
    cin >> A[i];
  for (int j=0; j<(N-1); ++j){
    Max=A[0];
	if(A[j+1]>A[j]) Max=A[j+1];
    }
  for (int k=0; k<(N-1); ++k){
    Min=A[0];
	if(A[k+1]<A[k]) Min=A[k+1];
	}
  for (int l=0; l<N; ++l){
    Sum += A[l];
	}
  cout<< (Sum-Max-Min)/(N-2) << endl;
  Sum=0;
  Max=0;
  Min=0;
 }
}

C++: #include <iostream>

using namespace std;

int main() {
	while (1) {
		int n;

		cin >> n;

		if (n == 0) {
			break;
		}

		int sum = 0, min = 1001, max = -1, temp;
		for (int i = 0; i < n; i++) {
			cin >> temp;

			sum += temp;

			if (min > temp) {
				min = temp;
			}
			if (max < temp) {
				max = temp;
			}
		}

		sum -= (min + max);

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

	return 0;
}

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

int main()
{
	int n;
	int score[1000];
	while(cin >> n){
		if(n==0)
			break;
		for(int i=0;i<n;i++){
			cin >> score[i];
		}
		sort(score, score+n);
		int sum = 0;
		for(int i=1;i<n-1;i++){
			sum += score[i];
		}
		cout << sum/(n-2) << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<functional>
#include<stack>
#include<vector>
#include<list>
#include<map>
#include<queue>
#include<cstring>
#include<deque>

//----------------------------------------
#define mrepp(i,n,x) for(int i = n-1; i >= x; i--)
#define mrep(i,n) mrepp(i,n,0)
#define repp(i,x,n) for(int i =x; i < n; i++)
#define rep(i,n) repp(i,0,n)

using namespace std;
//----------------------------------------


int main(void){
	for(int N; cin >> N && N;){
		int t[100];
		rep(i,N)
			cin >> t[i];
		sort(t,t+N);
		
		int to = 0;
		repp(i,1,N-1){
			to += t[i];
		}
		
		cout << to/(N-2) << endl;
	}
	
	return 0;
}