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++: int main()
{
    int n;
    while(1){
        cin >> x;
        if(x == 0) break;
        int max = -1, mini = 10000, sum = 0, ten = 0, y = 0;
        for(int i = 0; i < x; i++){
            cin >> ten;
            sum += ten;
           
            if(ten < mini) mini = ten;
	    if(ten > max) max = ten;
        }
        sum -= max + mini;
        y = sum / (x - 2);
        cout << y << endl;
    }
    return 0;
}

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

}

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

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

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

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	while (true) {
		int n; cin >> n;
		if (n == 0)break;

		VI a;
		rep(i, n) {
			int x; cin >> x;
			a.pb(x);
		}
		int min = *min_element(all(a));
		int max = *max_element(all(a));
		int ans = (accumulate(all(a), 0) - min - max) / (n - 2);
		cout << ans << endl;
	}
}

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

int main() {
  while(true) {
    int N; cin >> N;
    if(N == 0) break;
    vector<int> score(N);
    for(int i = 0; i < N; i++)
      cin >> score[i];
    sort(score.begin(), score.end());
    cout << accumulate(&score[1], &score[N-1], 0) / (N - 2) << endl;
  }
}

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

int main() {
    int n;

    while (true) {
        cin >> n;
        if (!n) break;
        bool bMax = false;
        bool bMin = false;
        int sum = 0;
        for (int i = 0; i < n; ++i) {
            int t; cin >> t;
            if (bMax == false && t >= 1000) bMax = true;
            else if (bMin == false && t <= 0) bMin = true;
            else sum += t;
        }
        cout << sum/(n-bMax-bMin) << endl;
    }
}

C++: #include <iostream>
using namespace std;
int main() {
    int N,input;
    while (1){
        cin >> N;
        if (N==0){
            break;
        }
        int sum=0,max=0,min=1001;
        for (int i;i<N;i++) {
            cin >> input;
            sum = sum+input;
            if (max < input) max = input;
            if (min > input) min = input;
        }
        cout << (sum-max-min)/(N-2) <<endl;
    }
}

C++: #include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
    int n;
    while(cin>>n,n){
        vint v(n);
        rep(i,n) cin>>v[i];
        sort(ALL(v));
        ll sum = 0;
        reep(i,1,n-1){
            sum += v[i];
        }
        // cout<<sum<<endl;
        cout << sum/(n-2) << endl;
    }
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

C++: #include <iostream>

using namespace std;

int main(void){
  while(1){
    int n;
    cin >> n;
    if(n == 0){return 0;}

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

    int sum = 0;
    int max = -1;
    int min = 1001;
    for(int i = 0 ; i < n ; i++){
      if(max < point[i]){max = point[i];}
      if(min > point[i]){min = point[i];}

      sum += point[i];
    }

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

}