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>
using namespace std;
int main(){
int judge;
int maxscore =0;
int minscore =0;
cin >> judge;
if(i != 0){
int score[judge];
	for(int i=0; i<judge; i++){
	cin >> score[i];
		if(score[i] > maxscore){
		maxscore = score[i];
		}
		if(score[i] < minscore){
		minscore = score[i];
		}
		if(i==0){
		minscore = score[0];
		}
	}
int lastscore = 0;
for(int j=0;j<judge;j++){
lastscore +=  score[j];
}
lastscore = (lastscore - maxscore - minscore)/(judge - 2);
cout << lastscore <<endl;
}
return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define int ll
typedef pair<int, int> pii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

signed main() {
    ios::sync_with_stdio(false);cin.tie(0);
    REP(_, 20) {
        int n; cin >> n;
        if (n == 0) break;
        vector<int> v;
        REP(i, n) {
            int x; cin >> x;
            v.push_back(x);
        }
        sort(v.begin(), v.end());
        int ans = 0;
        FOR(i, 1, n-1) ans += v[i];
        ans /= n - 2;
        cout << ans << endl;
    }
}

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

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;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  while (n > 0) {
    int sum = 0;
    int mx = 0;
    int mn = 10000;
    int x;
    for (int i = 0; i < n; i++) {
      cin >> x;
      sum += x;
      if (x > mx) mx = x;
      if (x < mn) mn = x;
    }
    cout << (sum - mx - mn) / (n - 2) << endl;
    cin >> n;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
	
	cin.tie( 0 );
	ios::sync_with_stdio( false );
    
	while(true){
        	int n;
        	cin >> n;
        
        	if(n == 0){ break; }
        	int MAX = INT_MIN ,MIN = INT_MAX;
        	vector<int> vc(n);
        
        	for(int i=0; i<n; i++){
            		cin >> vc[i];
            		MAX = max(MAX, vc[i]);
            		MIN = min(MIN, vc[i]);
        	}
        	auto res = (accumulate(vc.begin(), vc.end(), 0)) - (MAX + MIN);
        	cout << res / (n-2) << endl;
    	}
    	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){
  int n, cmax = 10000, cmin = -1;
  int sum=0,a;
  while(cin >> n, n){
    REP(i,n){
      cin >> a ;
      cmax = max(cmax,a);
      cmin = min(cmin,a);
      sum += a;
    }
    cout << (sum-cmax-cmin)/(n-2) << endl;
  }
  return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

int A[101];

int main()
{
	int n; 
	while(1) {
		cin >> n;
		if (!n) break;
		int minx = inf, maxx = 0, sum = 0;
		rep(i,0,n) {
			int t;
			cin >> t;
			minx = min(minx, t);
			maxx = max(maxx, t);
			sum += t;
		}
		sum -= minx + maxx;
		int ans = floor((double)sum / (n-2));
		cout << ans << endl;
	}

 	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[20];
    memset(data, 0, sizeof(data));
    
    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;
  }
  return 0;
}

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

int main(){
  int n, s, sum, max, min;
  while(1){
    cin >> n;
    if(n == 0) break;
    sum = 0;
    cin >> s;
    sum += s;
    max = s;
    cin >> s;
    sum += s;
    if(max < s){
      max = s;
    }else{
      min = s;
    }
    for(int i = 2; i < n; i++){
      cin >> s;
      sum += s;
      if(max < s){
	max = s;
      }else if(min > s){
	min = s;
      }
    }
    sum -= max;
    sum -= min;
    int ave = sum / (n-2);

    cout << ave << endl;
  }

  return 0;
}

C++: #include <stdio.h>
int main(){
  int n,s,i,min=1000,max=3,sum=0,ave;
  while(1){
    scanf("%d",&n);
    if(n==0){
      break;
    }
    for(i=0;i<n;i++){
      scanf("%d",&s);
      if(s<min){
    min=s;
      } 
      if(s>max){
    max=s;
      }
      sum=sum+s;
    }
    sum=sum-max-min;
    ave=sum/(n-2);
    printf("%d\n",ave);
    sum=0;
    min=1000;
    max=3;
  }
  return 0;
}

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

C++: #include<stdio.h>


int n;
int score[110];
int _max,_min;
int i;
int sum;
int ans; 

int main()
{
	
	for(;;)
	{
		_max = 0;
		_min = 100000;
		sum = 0;
		
		scanf("%d",&n);
		if(n == 0)break;
		
		for(i = 0;i < n;i++)
		{
			scanf("%d",&score[i]);
			if(score[i] < _min)
			{
				_min = score[i];
			}
			if(score[i] > _max)
			{
				_max = score[i];
			}
			sum += score[i];
			
		}
		
		ans =( sum - _max - _min) /(n - 2);
		
		printf("%d\n",ans);
		
	}
	
	return 0;
	
}