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 <vector>

using namespace std;

int main(){
	vector<int> array;
	int i,x,max,min,sum,n;
	max = 0;
	min = 1000;

	while(cin>>n){
	array.clear();
	sum=0;

	for(i=0;i<sizeof(array);i++){
		cin >> x;
		array.push_back(x);
	}
	for(i=0;i<n;i++){
		if(max<array[i]){
			max= array[i];
		}
	}
	for(i=0;i<n;i++){
		if(min>array[i]){
			min= array[i];
		}
	}
	for(i=0;i<sizeof(array);i++){
		sum += array[i];
	}
	sum = sum-max-min;
	cout << sum/sizeof(array) << endl; 
	}

}

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

int main(){
    int a,n;
    for(;;){
        vector<int> num;
        cin>>n;
        if(n==0) break;
        for(int i = 0; i < n; i++){
            cin>>a;
            num.push_back(a);
        }
        sort(num.begin(), num.end());
        num.erase(num.begin());
         num.pop_back();
        int sum=0;
        for(int x : num){
            sum+=x;
        }
        sum/=num.length();
        cout<<sum<<endl;
    }
    return 0;
}

C++: %:include <cstdio>
%:include <algorithm>
using namespace std;

int main() <%
  for(int tci = 0; ; tci++) <%
    int n; scanf("%d", &n);
    if(n==0) break;
    int minv = 1000, maxv=0, sum=0;
    for(int i = 0; i < n; i++) <%
      int x; scanf("%d", &x);
      minv=min(minv,x);
      maxv=max(maxv,x);
      sum+=x;
    %>
    printf("%d\n", (sum-maxv-minv)/(n-2));
  %>
  return 0;
%>

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

int score[100];
int n, i, k, ans;

int main() {
  for(;;) {
    scanf("%d", &n);
    if(n == 0) break;
    REP(i, n) scanf("%d", &score[i]);
    sort(score, score + n);
    int ans = 0;
    for(int j = 1; j <= n - 2; ++j) ans += score[j];
    printf("%d\n", ans / (n - 2));
  }
  return 0;
}

C++: #include <iostream>
#include <cmath>

using namespace std;

void find_max(int *data, int N){
  int flag = -1;
  int max = 0;
  for (int i=0; i<N; ++i){
    if (max < data[i]){
      max = data[i];
      flag = i;
    }
  }
  data[flag] = 0;
}

void find_min(int *data, int N){
  int flag = -1;
  int min = 1000000;
  for (int i=0; i<N; ++i){
    if (min > data[i]){
      min = data[i];
      flag = i;
    }
  }
  data[flag] = 0;
}

int main(void){
  int n;
  while (cin >> n){
    if (n == 0){
      return -1;
    }
    
    int *data = new int[n];
    
    for (int i=0; i<n; ++i){
      cin >> data[i];
    }
    find_min(data, n);
    find_max(data, n);
    int sum = 0;
    for (int i=0; i<n; ++i){
      sum += data[i];
    }
    int total = floor((double)sum/(n-2));
    cout << total << endl;
    delete[] data;
  }
  return 0;
}

C++: #include <iostream>

#define el endl
#define fd fixed

using namespace std;

int main() {
  while (1) {
    int n;
    cin >> n;
    int m = n;
    if (n == 0) break;
    int max = INT_MIN;
    int min = INT_MAX;
    int ave = 0;
    while (m--) {
      int x;
      cin >> x;
      ave += x;
      if (x < min) min = x;
      if (x > max) max = x;
    }
    ave = ave - (max + min);
    ave = ave / (n-2);
    cout << ave << el;
  }
}

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

#define ll long long

using namespace std;

int main(void) {
	while (true) {
		ll n;
		cin >> n;
		if (n == 0)break;
		vector<ll> s(n);
		for (int i = 0; i < n; i++) {
			cin >> s[i];
		}
		sort(s.begin(), s.end());
		ll ans = 0;
		for (int i = 1; i < n - 1; i++) {
			ans += s[i];
		}
		ans /= (n - 2);
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

int main(){
	int n,one;
	int sum = 0;

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

C++: #include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define int long long
using namespace std;
typedef long long int64;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    while(n != 0){
        vector<int> s(n);
        REP(i, n) cin >> s[i];
        int sum = accumulate(All(s), 0);
        sum -= *max_element(All(s)) + *min_element(All(s));
        sum /= (n-2);
        cout << sum << "\n";

        cin >> n;
    }
    return 0;
}

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

int main() {
  while(true) {
    int n;
    int s[200];
    int max = 0;
    int min = 1000;
    int total = 0;
    cin >> n;
    if(n == 0) break;
    for(int i = 0; i < n; ++i) {
      cin >> s[i];
      if(s[i] > max) max = s[i];
      if(s[i] < min) min = s[i];
      total += s[i];
    }
    cout << ((total - max - min) / (n - 2)) << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    while(1){
        vector<int> point;
        int n,x;
        long long sum=0;
        cin >> n;
        if(n==0)    break;
        while(n--){
            cin >> x;
            point.push_back(x);
        }
        sort(point.begin(),point.end());
        for(int i=1;i<point.size()-1;i++){
            sum+=point[i];
        }
        cout << sum/(point.size()-2) << "\n";
        point.clear();
    }
}

C++: #include <iostream>
using namespace std;
int main(){

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

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

int main()
{
  int n;
  while (cin >> n, n){
    int ma=0, mi=INT_MAX;
    int sum = 0;
    for (int i = 0; i < n; i++){
      int x; cin >> x;
      sum += x;
      ma = max(ma, x); mi = min(mi, x);
    }
    cout << (sum - mi - ma) / (n - 2) << endl;
  }
}

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

using namespace std;
typedef long long ll;

void solve(vector<int> &A) {
    sort(A.begin(), A.end());
    int N = A.size();
    ll sum = 0;
    for(int i = 1; i < N - 1; i++) {
        sum += A[i];
    }
    cout << sum / (N - 2) << endl;
}

int main() {
    int N;
    while(cin >> N, N) {
        vector<int> A(N);
        for(int i = 0; i < N; i++) cin >> A[i];
        solve(A);
    }
    return 0;
}