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<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<stack>
using namespace std;


int main(){
    int n;
    while(1){
        scanf("%d",&n);
        if(n==0)break;
        int sum=0,max=0,min=1000,point;
        for(int i=1;i<=n;i++){
            scanf("%d",&point);
            if(point>max) max=point;
            else if(point<min) min=point;
            sum+=point;
        }
        printf("%d\n",(sum-max-min)/(n-2));
    }
    
    return 0;
}

C++: #include<iostream>
#include<fstream>
#include<vector>
#include<algorithm> //???????????¨

using namespace std;

int main(){
	//ifstream fin("in.txt");

	vector<int> v;

	int average = 0;

	int n = 0;
	while (true){

		cin >> n;
		if (n == 0)break;

		//?????????
		average = 0;
		if (!v.empty())v.clear();

		for (int i = 0; i < n; i++){
			int tmp = 0;
			cin >> tmp;
			v.push_back(tmp);
		}
		sort(v.begin(), v.end());
		v.pop_back();
		v.erase(v.begin());

		for (int i = 0; i < v.size(); i++)
			average += v[i];

		average /= v.size();

		cout << average << endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll =  long long ;
using P = pair<int,int> ;
const int INF = 1e9;
const int MOD = 1000000007;

int main(){
    while(1){
        int n;
        cin >> n;
        if(n==0) break;
        vector<int> s(n);
        rep(i,n) cin >> s[i];
        int mx = 0,mn = INF,sum = 0;
        rep(i,n){
            sum += s[i];
            mn = min(mn,s[i]);
            mx = max(mx,s[i]);
        }
        cout << (sum-mn-mx)/(n-2) << endl;
    }
    return 0;
}

C++: 

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

float mean(vector<float> v) {
    int size = v.size();
    float sum = 0;
    for (int i = 0; i < size; i++){
        sum += v[i];
    }
    return sum / size;
}

int main(){

	while(1){
		int N;
		cin >> N;
		if(N == 0){
			break;
		}

		vector<float> data(N);

		rep(i,data.size()){
			cin >> data[i];
		}

		sort(data.begin(),data.end());
		
		data.pop_back();
		data.erase(data.begin());

		cout << int(mean(data)) << endl;
	}

	return 0;
}

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

int main() {
	while (cin >> N && N>0) { // By while (), adopt the form of std in 
		int sum = 0;
		int max = 0;
		int min = 0;
		for (int i=0; i<N; i++) {
			cin >> S;
			if (i==0) min = S; // initialize min
			sum += S; // calculate sum
			if (max < S) max = S; // search max
			if (min > S) min = S; // search min
		}
		int ans;
		ans = (sum-max-min)/(N-2);
		cout << ans << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int N,S;
int set = 0;
int main(){
  while(set <= 20){
    //while(cin >> N && N >= 3 && N <= 100) {
    cin >> N;
    if (N == 0) break;
    int largest = 0;
    int smallest = 1000;
    int sum = 0;
    for (int i = 0; i <N;++i) {
      cin >> S;
      if(largest < S) largest = S;
      if(smallest >S) smallest = S;
      sum += S;
    }
    cout << (sum - largest - smallest)/(N-2) << endl; 
  ++set;
  }
  return 0;
}

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

using namespace std;
int N, S;
int main() {
  while (cin >> N && N > 0) {
    int sum = 0;
    int m = 1001;
    int M = -1;
    for (int i = 0; i < N; ++i) {
      cin >> S;
      sum += S;
      m = min(m, S);
      M = max(M, S);
    }
    sum = sum - m - M;
    int ans = sum / (N-2);
     cout << ans << endl;
  }
  return 0;
}

C++: #include<cstdio>

bool solve(){
	int n,ma = 0,mi = 1000,sum = 0;
	scanf("%d",&n);
	if(n==0) return false;
	for(int i=0;i<n;i++){
		int s;
		scanf("%d",&s);
		if(s<mi) mi = s;
		if(s>ma) ma = s;
		sum += s;
	}
	printf("%d\n",(sum-ma-mi)/(n-2));
	return true;
}

int main(){
	while(solve()){}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n, s, maxn, minn;

  while(1){
    scanf("%d", &n);
    if(n==0) break;

    maxn=0;
    minn=1000;
    int x=0;
    for(int i=0;i<n;i++){
      scanf("%d", &s);
      x+=s;
      maxn=max(s,maxn);
      minn=min(s,minn);
    }

    printf("%d\n",(x-maxn-minn)/(n-2) );
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int judge;
int maxscore =0;
int minscore =0;
int maxnum;
int minnum;
cin >> judge;
int score[judge];
	for(int i=0; i<=judge; i++){
	cin >> score[i];
		if(score[i] > maxscore){
		maxscore = score[i];
		i=maxnum;
		}
		if(score[i] < minscore){
		minscore = score[i];
		i = minnum;
		}
	}
score[maxnum] = 0;
score[minnum] = 0;
int lastscore = 0;
for(int j=0;j<=judge;j++){
lastscore += score[j];
}
lastscore = lastscore/(judge - 2);
cout << lastscore <<endl;
return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int main(void){
	int32 n;
	while(cin >> n && n){
		vector<int32> x(n);
		int32 sum = 0;
		REP(i, n){
			cin >> x[i];
			sum += x[i];
		}
		cout << (sum-*(max_element(all(x)))-*min_element(all(x)))/(n-2) << endl;
	}
}

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

int main() {
  int n,s,total,max,min;
  while(cin>>n, n) {
    cin>>s;
    max = min = total = s;
    for(int i=0; i<n-1; ++i) {
      cin>>s;
      if(s < min) min = s;
      if(s > max) max = s;
      total += s;
    }
    total = total - min - max;
    cout<<total/(n-2)<<endl;
  }
}

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

C++: while true do
    max = -1
    min = 1001
    sum = 0
    n = gets.to_i
    break if n == 0
    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<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll INF=1000000000LL;
const ll MOD=1000000007LL;
const ll MAX=100010;
int main(){
	int n;
	while(cin>>n,n){
		int ma=0;
		int mi=INF;
		int sum=0;
		for(int i=0;i<n;i++){
			int s;
			cin>>s;
			sum+=s;
			ma=max(s,ma);
			mi=min(s,mi);
		}
		cout<<(sum-ma-mi)/(n-2)<<endl;
	}
	return 0;
}