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 <iostream>
#include <algorithm>

using namespace std;

int main(){
    int n;
    while(cin >> n && n){
        int mini = 1 << 29;
        int maxi = -1;
        int sum = 0;
        int tmp;
        for(int i=0;i<n;i++){
            cin >> tmp;
            mini = min(mini, tmp);
            maxi = max(maxi, tmp);
            sum += tmp;
        }
        cout << (sum - mini - maxi) / (n - 2) << endl;
    }
}

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

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

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

using namespace std;

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

C++: #include<iostream>
using namespace std;
int main() {
    while (1) {
        int n; cin >> n;
        if (n == 0) break;
        int sum = 0;
        int max, min;
        for (int i = 0; i < n; ++i) {
            int a; cin >> a;
            if (i == 0) max = min = a;
            max = max < a ? a : max;
            min = min > a ? a : min;
            sum += a;
        }
        sum -= max + min;
        cout << sum / (n - 2) << endl;
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main(void)
{
	int n;
	while(cin >> n, n > 0){
		int s, sum = 0, maxi, mini;
		cin >> s;
		sum += s;
		maxi = s;
		mini = s;
		for(int i = 1; i < n; i++){
			cin >> s;
			sum += s;
			maxi = max(maxi, s);
			mini = min(mini, s);
		}
		cout << (sum-maxi-mini)/(n-2) << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
class Score{
private:
	int shinpan;
	int score[100];
	int max;
	int min;
	int ave;
public:
	Score();
	//????????????????????¨????????????????????¨???
	void Reset();
	//???????????°?????\???
	void InputShinpan(int n){shinpan = n;}
	//?????°??????????????°?????¨?????\?????????
	void InputScore();
	//????????????????????????????????????????????°?????????
	int ReturnAverage();
};
Score::Score(){
	max=INT_MIN;
	min=INT_MAX;
	ave=0;
	shinpan=0;
	for(int i=0;i<100;i++){
		score[i] = INT_MIN;
	}
}
void Score::Reset(){
	max=INT_MIN;
	min=INT_MAX;
	ave=0;
	shinpan=0;
	for(int i=0;i<100;i++){
		score[i] = INT_MIN;
	}
}
void Score::InputScore(){
	for(int i=0;i<shinpan;i++){
		cin >> score[i];
	}
}
int Score::ReturnAverage(){
	for(int i=0;i<shinpan;i++){
		ave += score[i];
		if(score[i]>max){
			max = score[i];
		}
		if(score[i]<min){
			min = score[i];
		}
	}
	ave -= max;
	ave -= min;
	ave = ave / (shinpan - 2);
	return ave;
}
int main()
{
	int n;
	int i;
	Score score;
	while(cin>>n,n!=0){//???????????°?????\??? ?????§??????
		score.InputShinpan(n);
		score.InputScore();
		cout << score.ReturnAverage() << endl;
		score.Reset();
	}
	cin.get();
	return 0;
}

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

C++: #include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include <climits>

using namespace std;

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

typedef long long ll;

void solve(){
}

int main(){
  int n;

  while(cin>>n,n){
    int sum = 0;
    int max = INT_MIN;
    int min = INT_MAX;

    rep(i,n){
      int s;
      cin>>s;
      sum += s;

      if(max < s) max = s;
      if(min > s) min = s;
    }

    cout<<(sum - max - min) / (n-2)<<endl;
  }
}

C++: #include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
 
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
 
using namespace std;

int main(){

  while(true){

    int a;
    cin >> a;

    vector<int> list;

    if(a==0){
      break;
    }

    rep(i,a){
      int temp=0;
      cin >> temp;
      list.push_back(temp); 
    }

    sort(list.begin(),list.end());

    int ans=0;
    int count=0;
    REP(i,1,a-1){
      ans+=list[i];
      count++;
    }
    ans=(int)(ans/count);
    cout << ans << endl;
  }
  return 0;
}

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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define INF 1e09

using namespace std;

int main(){
  int n;
  int total, maxim, minim;
  int tmp;
  while(cin >> n and n){
    total = 0; maxim = -INF; minim = INF;
    REP(i, n) { cin >> tmp; total += tmp; maxim = max(maxim, tmp); minim = min(minim, tmp); }
    total -= (maxim + minim);
    cout << total / (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(1){
    int n;
    cin >> n;
    if(n==0){
      break;
    }
    vector<int> a(n);
    int ma=0;
    int mi=1000;
    int sum=0;
    rep(i,n){
      cin >> a[i];
      ma=max(a[i],ma);
      mi=min(a[i],mi);
      sum+=a[i];
    }
    sum=sum-mi-ma;
    int ave=sum/(n-2);
    cout << ave << endl;
  }
  return 0;
  
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        int n;
        cin >> n;
        if(n == 0) break;
        int maxi = -1;
        int mini = 1e9;
        int sum = 0;
        for(int i = 1; i <= n; i++) {
            int in;
            cin >> in;
            maxi = max(maxi, in);
            mini = min(mini, in);
            sum += in;
        }
        cout << (sum - maxi - mini) / (n - 2) << endl;

    }
    return 0;
}

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

int main(){
	while(1){
		int N, s, i, sum = 0, maxs = 0, mins = 1001;
		scanf("%d", &N);
		if(N == 0){
			return 0;
		}
		for(i = 0; i < N; i++){
			scanf("%d", &s);
			sum += s;
			maxs = max(maxs, s);
			mins = min(mins, s);
		}
		printf("%d\n", (sum - maxs - mins) / (N - 2));
	}
}