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 <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
using namespace std;

typedef vector<int> Ivec;
int main() {
	int n;
	
	while (scanf("%d", &n) != EOF) {
		if (n == 0)
			return 0;
		int Sum = 0, Max = -1, Min = 1001, num[2];
		for (int i = 0; n > i; i++) {
			int buf;
			scanf("%d", &buf);
			if (buf > Max) {
				Max = buf;
				num[0] = i;
			}
			if (buf < Min) {
				Min = buf;
				num[1] = i;
			}
			Sum += buf;
		}
		printf("%d\n", (int)((Sum - (num[0] == num[1] ? Max : Max+Min))/(n- (num[0] != num[1]) - 1)));
	}
	return 0;
}

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

int main(){
	int n, ma, mi, tmp, ans;
	while(cin >> n){
		if(n == 0) break;
		ma = 0;
		mi = 1001;
		ans = 0;
		for(int i = 0;i<n;i++){
			cin >> tmp;
			ans += tmp;
			mi = fmin(tmp,mi);
			ma = fmax(tmp,ma);
		}
		cout << int(ans - mi - ma)/(n-2) << endl;
	}
	return 0;
}

C++: #include <stdio.h>
int main(){
  int n,s,i,min=1000,max=0,sum=0,ave;
  while(1){
    scanf("%d",&n);
    if(3<=n&&n<=100){ 
      for(i=1;i<=n;i++){
     scanf("%d",&s);
      if(s<min){
    min=s;
      }
      if(s>max){
    max=s;
      }
      sum=sum+s;
   }
      sum=sum-max-min;
      ave=sum/(n-2);
      printf("%d\n",ave);
    }
    else if(n==0){
      break;
    }   
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
	int n;
	while ( cin >> n, n ) {
		int m = 10000, M = 0, sum = 0;
		for (int i = 0; i < n; ++i) {
			int v; cin >> v;
			sum += v;
			m = min(m, v);
			M = max(M, v);
		}
		cout << (sum - m - M) / (n-2) << endl;
	}
}

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

int main(){
  int a[101];
  int b[20];
  int n = 0;
  int i = 0;
  int max = 0;
  int min = 1000;
  int sum = 0;
  int counter = 0;
  while(1){
    max = 0;
    min = 1000;
    sum = 0;
    cin >> n;
    if(n==0) break;
    for(i=0;i<n;i++){
      cin >> a[i];
      if(max <= a[i]) max = a[i];
      if(min >= a[i]) min = a[i];
      sum += a[i];
    }
    b[counter] = (sum - max - min) / (n - 2);
    counter++;
  }
  for(i=0;i<counter;i++){
    cout << b[i];
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  int n, x, mx ,mn;
  int a[100] = {};
  double Sum,Sum2,Sum3;
  int Sum4;
  while(1){
    cin >> n;
    if(n == 0) break;
    for(int i=0;i<n;i++)cin >> a[i];
    mx = a[0];
    mn = a[0];
    for(int i=0;i<n;i++){
      mx = max(mx,a[i]);
      mn = min(mn,a[i]);}
    Sum = 0;
    for(int i=0;i<n;i++) Sum += a[i];
    Sum2 = Sum - mx - mn;
    Sum3 = Sum2 / (n-2);
    Sum4 = Sum3;
    cout <<  Sum4 << endl;
    for(int i =0; i<n;i++)a[i] = 0;
    

  }

  return 0;
}

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/n-2 << endl;
    }
}


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

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 n;
int main(){
	while(cin>>n&&n){
		int p;
		int pmax=-10000000,pmin=1000000;
		int sum=0;
		for(int i=0;i<n;i++){
			cin>>p;
			pmax=max(p,pmax);
			pmin=min(p,pmin);
			sum+=p;
		}
		cout<<(sum-(pmax+pmin))/(n-2)<<endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main()
{
        while(true)
        {
                int n,A[100]={0};
                cin>>n;
                if(n==0) break;
                rep(i,n) cin>>A[i];
                sort(A,A+n);

                int sum=0;
                rep(i,n-2) sum+=A[i+1];
                cout<<sum/(n-2)<<endl;
        }
        return 0;
}

C++: # encodign: utf-8

while true do
    # ????°??????§???????????? (?????????0??\???1000??\???)
    max = -1
    min = 1001
    # ????¨?????????????
    sum = 0
    # n??????
    n = gets.to_i
    break if n == 0 # 0?????¨????????????
    # n?????????????????????
    n.times do
        v = gets.to_i
        min = v if v < min
        max = v if v > max
        sum += v
    end
    sum -= (min + max)
    p sum / (n-2)
end

C++: #include<iostream>

using namespace std;

int main () {

  while (true){

    int n;
    int i;
    int s = 0;
    int mi = 0;
    int ma = 0;
    cin >> n;

    if (n == 0)
      break;
??????
??????int p[100];

    for (i=0,i<n,i++){
      cin >> p[i];

      if (p[i] < mi)
        mi << p[i];

      if (p[i] > ma)
        ma << p[i];

      s += p[i];

    }

    cout << (s - mi - ma) / (n-2)

  }

  return 0;

}