Go: /*
	Problem A: ICPC 得点集計ソフトウェア
	http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// 標準入力を取得するScannerのインスタンスを作成
var sc = bufio.NewScanner(os.Stdin)

// 標準入力で各行を読み込み文字列として返す
func readLine() string {
	if sc.Scan() {
		return sc.Text()
	}
	return ""
}

func average() (avg int) {
	// 審判の人数を取得する
	n, _ := strconv.Atoi(readLine())

	// 得点
	score := make([]int, 0, n)

	// 得点を読み込む
	for n > 0 {
		line, _ := strconv.Atoi(readLine())
		score = append(score, line)
		n--
	}

	if len(score) == 0 {
		return 0
	}

	// ソート
	sort.Ints(score)
	// 先頭を削除
	score = append(score[:0], score[1:]...)
	// 末尾を削除
	score = score[:len(score)-1]

	// 合計
	for i := 0; i < len(score); i++ {
		avg += score[i]
	}

	// 平均
	avg = avg / len(score)
	return avg
}

func main() {
	// 改行区切りから単語(スペース)区切りで読み込むように変更する
	sc.Split(bufio.ScanWords)
	for {
		avg := average()
		if avg != 0 {
			fmt.Println(avg)
		} else {
			break
		}
	}
}

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

using namespace std;

int main()
{
  int n;

  while(cin >> n, n){
    int mini = 114514, maxi = -114514;
    int sum = 0;

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

C++: #include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <utility>
#include <string>

using namespace std;

typedef long long int ll; 
typedef pair<int,int> Pii;

int main(){
    int n,tmp,maxN,minN;
    vector<int> ans;
    int tmpd;
    string num1,num2;
    while(1){
        cin>>n;
        if(n==0)break;
        tmpd=0;maxN=0;minN=1001;
        for(int i=0;i<n;i++){
            cin>>tmp;
            maxN = max(maxN,tmp);
            minN = min(minN,tmp);
            tmpd += tmp;
        }
        ans.push_back((tmpd-minN-maxN)/(n-2));

    }
    for(int i = 0;i<ans.size();i++){
        cout<<ans[i]<<endl;
    }

    return 0;
}

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

using namespace std;

int main(){

   while(1){
      int n;
      cin>> n;
      if(n==0){
         break;
      }
      int s[n];
      for(int i=0; i<n; i++) cin>> s[i];

      int sum=accumulate(s, s+n, 0);
      int mi=*min_element(s, s+n);
      int ma=*max_element(s, s+n);

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

   }

   return 0;
}

C++: #include <stdio.h>
int main()
{
  int n;
  while(scanf("%d", &n),n){
    int max=0,min=1000,s;
    long sum=0;
    for(int i=0; i<n; i++){
      scanf("%d",&s);
      sum+=s;
      max=max<s ? s : max;
      min=s<min ? s : min;
    }
    printf("%ld", (sum-min-max)/(n-2));
  }
}

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

int main()
{
	int in,a,maxer=0,miner=1000;
	int sum=0;
	int i=0;
	double ave=0.0;
	while( scanf("%d",&in) !=0 ){
		for(i=0; i<in; i++){
			cin >> a;
			maxer=max(a,maxer);
			miner=min(a,miner);
			sum += a;
		}
		sum = sum - maxer - miner;
		ave = sum/(in-2);
		cout << floor(ave) << endl;
		sum = maxer = ave = 0;
		miner=1000;
	}
}

C++: #include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
using namespace std;

#define ll long long
#define MP make_pair

int main(void) {
    int n;

    while(1){
        cin>>n;
        int s[100]={};
        double sum=0.0;
        if(n==0)break;

        for (int i = 0; i < n; i++) {
            cin>>s[i];
        }
        
        sort(s,s+n);
        for (int si = 1; si < n-1; si++) {
            sum+=double(s[si]);
        }
        
        double ave = sum/(double)(n-2);
        cout<<int(ave)<<"\n";

    }
    
    return 0;
}

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

int main(){

  
  int n;
  int sum;
  int s;
  int max,min;

  while(cin >> n){
    if(n==0){ break; }
    sum = 0;
    max=0,min=1000;

    for(int i=0; i<n; i++){
      cin >> s;
      if(s>max){ max=s; }
      if(s<min){ min=s; }

      sum += s;
    }

    sum -= max+min;

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

  }


  return 0;
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int getAverageScore(int N, VI S){
	int min = S[0];
	int max = S[0];
	int sum = 0;
	FOR(i, 1, N){
		sum += S[i];
		if (min > S[i]){ min = S[i]; }
		if (max < S[i]){ max = S[i]; }
	}
	sum -= (min + max);
	return sum / N;
}
int main(){
	int N;
	VI S;
	int b;
	while (true){
		cin >> N;
		if (N == 0){ break; }
		REP(i, N){
			cin >> b;
			S.push_back(b);
		}
		cout << getAverageScore(N, S)<<endl;
		S.clear();
	}
	return 0;
}

C++: #include <iostream>

using namespace std;
int main(){
	int zero;
	while(1){
		
		int N;
		int* score;
		int S = 0;
		int max = 0;
		int min = 0;
	
		cin >> N;
		
		if(N == 0){
			return 0;
		}
		
		score = new int[N];
		for(int i=0; i<N; ++i){
			cin >> score[i];
			S += score[i];
		
			if( max < score[i] ){
				max = score[i];
			}
			if( min > score[i] ){
				min = score[i];
			}
		}
		S -= max;
		S -= min;
	
		cout << (int)S/(N-2) << endl;

		delete[] score;
	}

}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
 
  while( true ) {
    long long int n;
    long long int a = 0;
    long long int b = 0;
    int input[100];
    cin >> n;
 
    if ( n == 0 ) break;
  
    for ( long long int i = 0; i < n; i++ ) {
 
      cin >> input[i];

      if (input[i] < a)
        a << input[i]

      if (input[i] > b)
        b << input[i] 
    }
 
    long long int ans = 0;
 
    for ( long long int i = 0; i < n; i++ ) {
 
      ans += s[i];
 
    }
 
    cout << (ans - a - b) / ( n - 2 ) << endl;
 
  }
 
  return 0;
 
}

C++: #include<stdio.h>

int INF = 1e9;

int main(){
	int n;
	int s[100];
	
	
	while(1){
		scanf("%d",&n);
		if(n == 0)break;
		int sum = 0;
		int avg = 0;
		int min = INF;
		int max = 0;
		for(int i = 0;i < n;i++){
			scanf("%d",&s[i]);
			sum += s[i];
			if(max < s[i]) {max = s[i];}
			else if(min > s[i]) {min = s[i];}
		}
		sum = sum - min - max;
		avg = sum / (n - 2);
		printf("%d\n", avg);
	}
}