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

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for	{
		n := nextInt(sc)
		if n == 0 { break }

		score_list := []int{}
		for i := 0; i < n; 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))
	}
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

C++: #include<iostream>
using namespace std;
 
int main(){
    int n,i;
	//cout<< "1000*100 = " << 1000*100 << "\n" << "int_max = " << INT_MAX << "\n";
    while(cin >> n,n){
        int point[100]={0,};
        int min = 1000;
        int max = 0;
		int total = 0;
        //if(!n) break;
        for(i=0;i<n;i++){
            cin >> point[i];
            if(point[i] > max) max = point[i];
            if(point[i] < min) min = point[i];
			total += point[i];
        }
        cout << (total-max-min)/(n-2) << "\n";
    }

}

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

int main(){
  while( cin >> N && N > 0){ //N??????????????????????????????????????§while????????????
    int sum = 0; 
    int min = 1001; //min????°?????????¨?????????
    int max = -1;
    int average = -1;

    for (int i = 0; i < N; i++){
      cin >> S;
      sum += S;
      if( S > max ) max = S;
      if(S < min) min = S; 
    }

    average = sum - min - max / N - 2; //???N-2?????§???????????¨?????¨??????

    cout << sum << endl;
  }

  return 0;
}

C++: # include <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;


int main() {
  int n;

  while (cin >> n) {
    if (n == 0) return 0;

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

    int  sum = 0;
    int _max = scr[0];
    int _min = scr[0];

    for (int s : scr) {
      sum  += s;
      _min = min(_min, s);
      _max = max(_max, s);
    }

    sum -= _max;
    sum -= _min;

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

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

int main()
{
    int n;
    while(cin>>n){
        
        if(n==0){
            break;
        }
        priority_queue<int> maxpq;
        int a, b=0;
        
        for(int i=0; i<n; i++){
            cin >> a;
            maxpq.push(a);
        }
        
        maxpq.pop();
        
        for(int i=0; i<n-2; i++){
            b +=maxpq.top();
            maxpq.pop();
        }
        
        cout << b/(n-2) << endl;
    }
    
    return 0;
}

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

int main(){
    int n;

    while(cin >> n, n != 0){
        vector<int> s;
        for(int i=1; i<=n; i++){
            int tmp;
            cin >> tmp;
            s.push_back(tmp);
        }
        sort(s.begin(), s.end());


        s.at(0) = 0;
        s.at(s.size()-1) = 0;

        vector<int>::iterator it = s.begin();
        int sum = 0;
        while(it != s.end()){
            sum += *it;
            it++;
        }
        cout << sum / (s.size()-2) << endl;
    }
    return 0;
}

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

int main(){
  
  int n;

  while(cin>>n && n){
    int nmax=0,nmin=100000,s,ans=0;
    for(int i=0;i<n;i++){
      cin>>s;
      ans+=s;
      nmax=max(nmax,s);
      nmin=min(nmin,s);
    }
    cout<<(ans-nmax-nmin)/(n-2)<<endl;
  }

  return 0;
}

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

#define FOR(i, a, n) for(int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  vector<int> a;

  while(true){
    vector<int> a;
    cin >> N;

    if(N == 0) break;

    int b;
    REP(i, N) {
      cin >> b;
      a.push_back(b);
    }

    sort(a.begin(), a.end());

    int sum = 0;
    FOR(i, 1, N - 1) {
      sum += a[i];
    }
    sum = sum / (N - 2);
    
    cout << sum << endl;

  }




}

C++: #include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>
#include <vector>
#include <stack>

using namespace std;


int main(){
	int n;

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

		int score[n];
		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];
		}
		sum = sum / (n-2);

		cout << sum << endl;
	}
	return 0;
}

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

int main()
{
	int x[20], y, i, j, n, sum = 0;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> x[i];
	}
	sort(x,x+n);
	for (i = 1; i < n - 1; i++)
	{
		sum += x[i];
	}
	cout << sum / (n - 2);
	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>

#define REP(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define ALLOF(c) c.begin(), c.end()
#define EPS 1e-9
using namespace std;

template <class T>
static T read()
{
	T t;
	cin >> t;
	return t;
}

template <class T>
static vector<T> read_n(int n)
{
	vector<T> v;
	REP(i,n) { v.push_back(read<T>()); }
	return v;
}

template <class T>
static void write(const T &t)
{
	cout << t << endl;
}

/// template end ///

int main()
{
	while (true)
	{
		int n = read<int>();
		if (!n) { break; }
		vector<int> v = read_n<int>(n);
		sort(ALLOF(v));
		int ret = accumulate(v.begin() + 1, v.end() - 1, 0) / (n - 2);
		write(ret);
	}
	return 0;
}