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++: #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

#define Rep(b, e, i) for (int i = b; i <= e; i++)
#define Repr(e, b, i) for (int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n - 1, i)
#define repr(n, i) Repr(n - 1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)), (x).end())

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1 <<29;
const int MOD = 1000000007;

void solve(void) {
  while (1) {
    int N;
    scanf("%d\n", &N);
    if (N == 0) break;
    vector<int> ps;
    rep(N, i) {
      int p;
      scanf("%d\n", &p);
      ps.pb(p);
    }
    sort(all(ps));
    int ans = ps[0] + ps[N - 1];
    for (int t : ps) {
      if (t != ps[0] && t != ps[N-1]) ans += t;
    }
    printf("%d\n", ans / N);
  }
}

int main(void) {
  solve();
  return 0;
}

C++: #include <stdio.h>

int sumSB(int n,int s[]){

int i,re,min = s[0],max = s[0];

for(i = 0;i < n;i++){
	if(min > s[i]){
		min = s[i];
	}
	
	else if(max < s[i]){
		max = s[i];
	}
	
}

return(min + max);
}

int main(void){
	int n,i,sum = 0,score[128],ave;
	
	while(1){
		scanf("%d",&n);
		if(n == 0) break;
		
		for(i = 0;i < n;i++){
			scanf("%d"&score[i]);
			sum += score[i];
		}
		sum -= sumSB(n,score);
		
		ave = sum / (n - 2);
		
		printf("%d",ave);
	}	
		return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n;
vl ans;

int main(){
  while(cin >> n){
    if(n == 0) break;
    vl s;
    for(ll i = 0;i < n;i++){
      ll x;
      cin >> x;
      s.push_back(x);
    }
    ll x = 0;
    x = accumulate(s.begin(),s.end(),0ll);
    x -= *max_element(s.begin(),s.end());
    x -= *min_element(s.begin(),s.end());
    ans.push_back(x/(s.size()-2));
  }
  for(ll x : ans){
    cout << x << endl;
  }

}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

int main() {
    while (true) {
        Int n;
        cin >> n;
        if (n == 0) break;
        vector<Int> v(n);
        for (Int i = 0; i < n; i++) {
            cin >> v[i];
        }
        sort(all(v));
        Int sum = 0;
        for (Int i = 1; i < n - 1; i++) {
            sum += v[i];
        }
        dump(sum / (n - 2));
    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
int num;
while(true)
{
int ans = 0;
cin >> num;
if(num != 0)
{
int a[num];
for(int i = 0;i<num;i++)
{
 cin >> a[i];
}
sort(a, a + num);
for(int i=1; i<num-1;i++)
{
ans += a[i];
}
cout << ans << endl;
}
else
{
return 0;
}
}
}

C++: #include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(void){

while(true){
  int n, input; cin >> n;
  if(n == 0)     break;
  
  int max_point = 0, min_point = 1000, sum = 0;
  for(int i = 0 ; i < n ; i++){
    cin >> input;
    min_point = min(min_point , input);
    max_point = max(max_point , input);
    sum += input;
  }
  sum -= min_point + max_point;

  cout << sum / (n - 2) << endl;

}

  return 0;
}

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

using namespace std;

int main() {
	while (true) {
		int n, sum, avg;
		cin >> n;
		if (n == 0) {
			break;
		}

		sum = 0;
		int max_score = -1, min_score = 1001;
		for (int i = 0; i < n; i++) {
			int tmp;
			cin >> tmp;
			min_score = min(min_score, tmp);
			max_score = max(max_score, tmp);
			sum += tmp;
		}
		sum -= min_score + max_score;
		avg = sum / (n - 2);
		cout << avg << endl;
	}

	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n, s, t, M, m, h;
	while(1){
		cin >> n;
		if(not n) break;
		t = 0;
		M = 0;
		m = 1001;
		for (int i = 0; i < n; ++i){
			cin >> s;
			t += s;
			M = max(M, s);
			m = min(m, s);
		}
		cout << (t-M-m) / (n-2) << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;


int main()
{
	int n;
	while (scanf("%d", &n) != EOF) {
		if (n == 0)
			break;
		int sum = 0, max_s = -1, min_s = 1001;
		for (int i = 0; i < n; ++i) {
			int s;
			scanf("%d", &s);
			sum += s;
			max_s = max(max_s, s);
			min_s = min(min_s, s);
		}

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

	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int a[2020];
  int x,i = 0;
  while (cin >> x){
    a[i++] = x;
  }
  void saiten(int* a,int b);
  saiten(a,0);
}
void saiten(int* a,int j){
  int max = 0, min = 1000, ave = 0; 
  if (a[j] != 0){
    for (int k = j+1; k <= j+a[j]; k++){
      if (max < a[k])
	max = a[k];
      if (min > a[k])
	min = a[k];
      ave += a[k];
    }
    ave = (ave - max - min)/(a[j]-2);
    cout << ave << endl;
    saiten(a, j+a[j]+1);
  }
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	int y[20] = { 0 };
	int max;
	int min;
	n = 1;
		int j = 0;
		while (n != 0){
			
			cin >> n;
			max = 0;
			min = 1000;
				y[j] = 0;
			for (int i = 0; i < n; i++){
				cin >> x[i];
				int x[1000] = { 0 };
				if (max < x[i]) max = x[i];
				if (min > x[i]) min = x[i];
				y[j] += x[i];
			}
			y[j] = y[j]-max - min;
			y[j] = y[j] / (n - 2);
			j++;
		}
	for (int k = 0; k < j; k++){
		cout << y[k]<< endl ;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
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;
        }
        printf("%d\n", (sum-max-min)/(N-2));
    }
}

C++: #include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
  int n;
  while(cin >> n,n){
    vector <ll> a(n);
    REP(i,n)
      cin >> a[i];
    sort(a.begin(),a.end());
    ll sum = 0;
    rep(i,1,a.size()-1){
      sum += a[i];
    }
    cout << sum/(n-2) << endl;
  }
  return 0;
}