Go: /*
	Problem A: ICPC 得点集計ソフトウェア
	http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp
*/

package main

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

// 標準入力を取得するScannerのインスタンスを作成
var sc = bufio.NewScanner(os.Stdin)

// 標準入力で各行を読み込み文字列として返す
func readLine() string {
	if sc.Scan() {
		return sc.Text()
	}
	return ""
}

func average() (avg int) {
	// 審判の人数を取得する
	n, _ := strconv.Atoi(readLine())

	// 得点
	score := make([]int, 0, n)

	// 得点を読み込む
	for n > 0 {
		line, _ := strconv.Atoi(readLine())
		score = append(score, line)
		n--
	}

	if len(score) == 0 {
		return 0
	}

	// ソート
	sort.Ints(score)
	// 先頭を削除
	score = append(score[:0], score[1:]...)
	// 末尾を削除
	score = score[:len(score)-1]

	// 合計
	for i := 0; i < len(score); i++ {
		avg += score[i]
	}

	// 平均
	avg = avg / len(score)
	return avg
}

func main() {
	// 改行区切りから単語(スペース)区切りで読み込むように変更する
	sc.Split(bufio.ScanWords)
	for {
		avg := average()
		if avg != 0 {
			fmt.Println(avg)
		} else {
			break
		}
	}
}

C++: #include<algorithm>
#include<iostream>
#define rep(i,a) for(int i=0;i<(a);++i)

int n;

int main()
{
	while( std::cin >> n )
	{
		int ma = 0, mi = 1001, S = 0;
	
		rep( i, n )
		{
			int a;
			std::cin >> a;
			ma = std::max( ma, a );
			mi = std::min( mi, a );
			S += a;		
		}
		
		std::cout << (S-ma-mi)/n << std::endl;
	}

	return 0;
}

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;
}