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>
using namespace std;

int main() {
	int n, max, min, s;
	long sum;

	while (true) {
		cin >> n;
		sum = max = 0;
		min = 1000;

		if (n == 0)	break;

		for (int i = 0; i < n; i++) {
			cin >> s;
			if (s < min)	min = s;
			if (s > max)	max = s;
			sum += s;
		}
		sum -= (min + max);
		cout << sum / (n - 2) << endl;
	}
	return 0;
}

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

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

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

int main() {
  int max, min, sum, num, judge;
  while (true) {
    sum = 0;
    min = 1000;
    max = 0;
    cin >> num;
    judge = num;
    if (num == 0) break;
    for (int i = 0; i < judge; i++) {
      cin >> num;
      if (max < num) max = num;
      if (min > num) min = num;
      sum += num;
    }
    int result = (sum - max - min) / (judge - 2);
    cout << result << endl;
  }
  return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>

int main(){
  int s;
  int n;
  int i;
  int ans=0;
  while(1){
    scanf("%d",&n);
    if(n==0){break;}
    for(i=0;i<n;i++){
      int k;
      scanf("%d",&k);
      ans+=k;
    }  
    printf("%d\n",ans);
  }

}

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

int main(){
	int n;
	while(cin >>n){
		if(n == 0) break;
		vector<int> vec;
		int tmp, max, min;
		cin >>tmp;
		vec.push_back(tmp);
		max = tmp;
		min = tmp;
		bool maxb = true, minb = true;
		for(int i = 1; i < n; i++){
			cin >>tmp;
			vec.push_back(tmp);
			if(tmp < max) max = tmp;
			if(tmp > min) min = tmp;
		}
		int sum = 0;
		for(int i = 0; i < vec.size(); i++){
		if(vec[i] == max && maxb){
			maxb = false;
		} else if(vec[i] == min && minb){
			minb =false;
		} else{
			vec[i] += sum;
		}
		cout <<sum <<endl;
		return 0;
	}
}

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

C++: #include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main() {
	while (1) {
		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());
		int sum = 0;
		for (int i=1; i<n-1; i++) sum += score[i];
		cout << sum/(n-2) << endl;
	}
	
	return 0;
}

C++: int main() {
	while(true){
		int number;			//?????£??????????????°
		cin >> number;
		if(number == 0){exit(0);}

		int score[number];
		int i;
		for(i=0;i<number;i++){	//???????????????
			cin >> score[i];
		}

		int max = 0;			//????????????
		int maxJ;				//?????????????????????????????£??????
		int min = 1001;
		int minJ;
		for(i=0;i<number;i++){	//??????????????¨????°??????????????????????
			if(max < score[i]){
				maxJ = i;
			}
			if(score[i] < min){
				minJ = i;
			}
		}

		int sum = 0;
		for(i=0;i<number;i++){
			if(i != maxJ && i != minJ){
				sum += score[i];
			}
		}
		cout << sum << endl;

	}
	return 0;
}

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

int main() {

  long N;
  std::vector<long> v;
  long temp;
  long ans;
  long total;

  for(;;) {
    v.clear();
    std::cin >> N;
    if( N == 0 ) break;
    for(int i = 0; i < N; ++i) {
      std::cin >> temp;
      v.push_back(temp);
    }
    std::sort(std::begin(v), std::end(v));
    total = 0;
    for(int i = 1; i < N-1; ++i) total += v[i];
    ans = total / (N-2);
    std::cout << ans << std::endl;
  }


  return 0;
}

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

int main(){
  while( cin >> N && N > 0){
    int sum = 0; 
    int min = 0;
    int max = 0;
    int average = 0;
    for (int i = 0; i < N; cin >> S)
    {
      sum += S;
      if( S > max ) max = S;
      else if(S < min) min = S; 
    }
    average = sum - min - max / N; 

    cout << average << endl;
  }

  return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-8;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};



main(){
  int n;
  while(cin>>n,n){
    vector<int> in;
    int sum=0;
    rep(i,n){
      int t;
      cin>>t;
      sum+=t;
      in.pb(t);
    }
    sort(ALL(in));
    sum-=in[0]+in.back();
    cout<<sum/(n-2)<<endl;
    
    
  }
}

C++: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename T = int>inline T in() { T x; cin >> x; return x; }
#define REP(i,n) for(ll i=0;i<(n);++i)
#define REP1(i,n) for(ll i=1;i<=(n);++i)
#define REPI(i,ini,n) for(ll i=(ini);i<(n);++i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b) (((a)+(b)-1)/(b))
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1e9
#define INFL static_cast<ll>(INF)
int main()
{
	while (true)
	{
		int n = in();
		if (n == 0)break;
		vector<int>s(n);
		REP(i, n)s[i] = in();
		sort(ALL(s));
		int sum = 0;
		REP1(i, s.size() - 2)sum += s[i];
		cout << sum / (n - 2) << endl;
	}
}

C++: #include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#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 MAX 20
using namespace std;

int main(void){
  while(true){
    int n;  cin >> n;
    if(n==0)  break;
    int s[MAX], sum=0;
    rep(i, n) cin >> s[i];
    sort(s, s+n);
    FOR(i, 1, n-1)  sum += s[i];
    cout << sum/(n-2) << endl;

  }
  return 0;
}