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<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  while(N != 0){
    vector<int> A(N);
    rep(i,N){
      cin >> A[i];
    }
    sort(A.begin(),A.end());
    int sum = 0;
    for(int i=1; i<N-1; i++){
      sum += A[i];
    }
    cout << sum/(N-2) << endl;
    cin >> N;
  }
  return 0;
}

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

using namespace std;

int main()
{
    for (;;) {
        int n, s[100];

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

        for (int i = 0; i < n; ++i)
            scanf("%d", &s[i]);

        sort(s, s + n);

        int sum = 0;
        for (int i = 1; i < n - 1; ++i)
            sum += s[i];

        printf("%d\n", sum / (n - 2));
    }

    return 0;
}

C++: int maximum = 0;
    for (int i=1; i<S; ++i)
        for (int j=i; j<S; ++j)
            if (tax(X,i)+tax(X,j) == S) // (*)
              maximum = max(maximum, tax(Y,i)+tax(Y,j));

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

int main(){
  int n,s;
  
  while(cin>>n && n!=0){
    int sum=0;
    int largest=0;
    int smallest=1000;
    
    for(int i=1;i<=n;i++){
      cin>>s;
      sum+=s;
      if(largest<s)  largest=s;
      if(smallest>s) smallest=s;
    }
    int result=sum-largest-smallest;

    cout<<(int)(result/(n-2))<<endl;
}

}

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

int main(){
    int n;

    while(cin>>n,n){
        vector<int> v(n);

        for(auto &t:v){
            cin>>t;
        }

        sort(v.begin(),v.end());
        cout << accumulate(v.begin()+1,v.end()-1,0) / (n-2) << endl;
    }
}

C++: #include<cstdio>
#include<cstdlib>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;

int main(){
  int n,min,max,result;
  int score[100];

  while(true){

    cin >> n;
    if(n == 0) break;

    result = 0;
    min = 1000;
    max = 0;

    REP(i,n){
      int score;
      cin >> score;
      if(max < score) max = score;
      if(min > score) min = score;
      result += score;
    }
    cout << (result - max - min)/(n-2) << endl;
  }
  return 0;
}

C++: //#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;


// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T>
constexpr int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F>
constexpr int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T>
void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C>
void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U>
constexpr void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U>
constexpr void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C>
constexpr void reverse(C& c) { reverse(ALL(c)); }
template<typename C>
constexpr void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred>
constexpr void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9+7)
#pragma endregion


int main()
{
    int n;
    while(cin>>n) {
        if(n==0) break;
        vi v(n);
        rep(i,n) {
            cin >> v[i];
        }
        sort(v);
        remove(v,n-1);
        remove(v,0);
        P(accumulate(ALL(v),0)/v.size());
    }
    return 0;
}

C++: #include <bits/stdc++.h>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;


int a[1010];

int main(void){
	int n;
	while(1){
		cin >> n;
		if(n==0) break;
		rep(i,n) cin >> a[i];
		cout << (accumulate(a,a+n,0)-*max_element(a,a+n)-*min_element(a,a+n))/(n-2) << endl;
	}
}

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

int main() {
    int n;

    while (true) {
        cin >> n;
        if (!n) break;
        vector<int> a(n);
        int sum = 0;
        for (int i = 0; i < n; ++i) cin >> a[i];
        sort(a.begin(), a.end());
        for (int i = 1; i < n-1; ++i) {
            sum += a[i];
        }
        cout << sum/(n-2) << endl;
    }
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n;
	while(cin>>n and n>0){
		int s[n]; rep(i,n) cin>>s[i];
		sort(s,s+n);
		int sum=0;
		for(int i=1;i<n-1;i++){
			sum+=s[i];
		}
		int ans=sum/(n-2);
		cout<<ans<<endl;
	}

	return 0;
}