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 <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
 
using namespace std;
 
int main()
{
    int n;
    while(1){
        cin >> n;
        if(n == 0) break;
        int max = -1, min = 10000, sum = 0, score = 0, ans = 0;
        for(int i = 0; i < n; i++){
            cin >> score;
            sum += score;
            if(score > max) max = score;
            else if(score < min) min = score;
        }
        sum -= max + min;
        ans = sum / (n - 2);
        cout << ans << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define all(c) (c).begin(), (c).end()
using namespace std;
int S[1001] = {0};

int main() {
	int N;

	while(true) {
		cin >> N;

		if (N == 0) { break; }
		rep(i,N) {
			cin >> S[i];
		}
		sort(S,S+N);
		int ave = accumulate(S+1,S+N-1,0) / (N-2);
		cout << ave << endl;
	}
	

	return 0;
}

C++: #include <iostream>
#include <cstdio>	
#include <cstring>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

const int MAX_S = -1;
const int MIN_S = 1001;
int score[1001];

int main()
{
	int n, m;
	while (scanf ("%d", &n ) && n ){
		memset (score, 0, sizeof (score ) );
		int max_s = MAX_S;
		int min_s = MIN_S;
		rep (i, n ){
			int in;
			scanf (" %d", &in );
			score[in]++;
			max_s = max (max_s, in );
			min_s = min (min_s, in );
		} // end rep
		score[max_s]--;
		score[min_s]--;
		int sum = 0;
		int sum_n = 0;
		for (int i = 0; i <= 1000; i++ ){
			sum += i*score[i];
			sum_n += score[i];
		} // end for
		int res = sum/sum_n;
		printf ("%d\n", res );
	} // end loop
		
	return 0;
}

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

using namespace std;

const int MAX_N = 100;
int pts[MAX_N];
int n;

int main() {
	while (true) {
		cin >> n; if (n <= 0) break;
		for (int i = 0; i < n; ++i) 
			cin >> pts[i];
		sort(pts, pts + n);

		long pt = 0;
		for (int i = 1; i < n-1; ++i)
			pt += pts[i];

		cout << pt / (n-2) << endl;
	}

	return 0;
}

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>>s[i];
    }
    sort(s,s+n);
    int ans=0;
    for(int i=1;i<n-1;i++){
      ans+=s[i];
    }
    cout<<ans/(n-2)<<endl;
  }
  return 0;}

C++: #include <iostream>
#include <string>
#include <queue>
#include <numeric>
#include <algorithm>
using namespace std;

int main(){

	int n;
	while(cin >> n, n){
		int sum=0, s_max=0, s_min=10000;
		for(int i=0; i<n; i++){
			int s; cin >> s;
			sum += s;
			s_max = max(s_max, s);
			s_min = min(s_min, s);
		}
			cout << (sum - s_max - s_min)/(n-2) <<endl;
	}

	return 0;
}

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

int main()
{
    int a,b[100];
    cin>>a;
    int max=0,min=100,sum=0,result;
    for(int i=0;i<a;i++){
        cin>>b[i];
        sum+=b[i];
        if(b[i]<min){
            min=b[i];
        }
        else if(b[i]>max){
            max=b[i];
        }
    }
    result=sum-min-max;
    cout<<result/(a-2);
    return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>

int main(void) {
	int sinpan;
	int input;
	int score_sum;
	int smax, smin;
	
	while(1){
		scanf("%d", &sinpan);
		if ( sinpan == 0 ) { break; }
		
		score_sum = 0;
		smax = 0;
		smin = 1000;
		
		for ( int i=0; i<sinpan; i++ ) {
			scanf("%d", &input);
			score_sum += input;
			if ( smax < input ) { smax = input; }
			if ( smin > input ) { smin = input; }
		}
		printf("%d\n", (int)( (score_sum-smax-smin)/(sinpan-2)));

	}
	
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(int argc, char *argv[])
{
  for(;;) {
    int n;
    cin >> n;
    if(n == 0) break;
    vector<int> ss;
    for(int i = 0; i < n; i++) {
      int s;
      cin >> s;
      ss.push_back(s);
    }
    sort(ss.begin(), ss.end());
    int sc = 0;
    for(int i = 1; i < n-1; i++) {
      sc += ss[i];
    }
    cout << (sc / (n-2)) << endl;
  }
  return 0;
}

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

#define FOR(i,l,n) for(int i=(l);i<(n);i++)
#define REP(i,n) FOR(i,0,n)
#define MAX_JUDGE 100
using namespace std;

int main(){
  int n,score[MAX_JUDGE];
  while(cin>>n,n){
    REP(i,n)cin>>score[i];
    sort(score,score+n);
    int sum = accumulate(score+1,score+n-1,0);
    cout << sum/(n-2) <<endl;
  }
  return 0;
}

C++: //
//  main.cpp
//  ttt
//
//  Created by ??§?£? ??? on 2015/04/23.
//  Copyright (c) 2015??´ ??§?£? ???. All rights reserved.
//

#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    int n;
    while(cin >> n,n!=0){
    int max;
    int min=1005;
    int sum = 0;
    max = 0;
    int x;
    for(int i = 0;i < n;i = i+1){
        cin >> x;
        sum = sum + x;
        if(x > max){
            max = x;}
        if(x<min)
            min = x;
    }
        cout << (sum-min-max)/(n-2)<< endl;}
    return 0;
}

C++: #include <iostream>

int main()
{

    while(1) {
        int judgeNum = 0;
        int pointSum = 0;
        int maximumPoint = 0;
        int minimumPoint = 1000;

        std::cin >> judgeNum;
        if (judgeNum == 0) {
            break;
        }

        for(int i = 0; i < judgeNum; i++) {
            int point;
            std::cin >> point;
            if(point > maximumPoint) {
                maximumPoint = point;
            } else if (point < minimumPoint) {
                minimumPoint = point;
            }
            pointSum += point;
        }

        int answerSum = pointSum - maximumPoint - minimumPoint;

        std::cout << answerSum / (judgeNum - 2) << std::endl;
    }
    return 0;
}

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

  while( cin>>n && n ){
    int sum=0;
    mx = -1;
    mn = 10000;
    for( int i=0,j;i<n;i++ ){
      cin >> j;
      sum +=j;
      if( j>mx ) mx=j;
      else if( j<mn ) mn =j;
    }
    sum = sum - mx -mn;
    cout << sum/(n-2) << endl;
  }
  return 0;
}

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

using namespace std;

int main(){
	int n;
	int a[100];
	cin >> n;
	for (int i = 0; i < n; ++i){
		int m, j = 0;
		while(cin >> m,m){
			a[j] = m;
			j++;
		}
		sort(a,a+j+1);
		int sum = 0;
		for (int k = 1; k < j; ++k){
			sum += a[k];
		}
		cout << (sum / j-1) << endl;
	}
	return -;
}

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

int main() {
	while (true) {
		int n;
		cin >> n;

		if (n == 0) break;

		vector<int> score(n);

		for (int i = 0; i < n; i++) {
			cin >> score.at(i);
		}

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

		int sum = 0;

		for (int i = 1; i < n - 1; i++) {
			sum += score.at(i);
		}

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