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>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

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

        vector<int> vec(n);
        rep(i, n) cin >> vec[i];

        int ans = accumulate(all(vec), 0);
        sort(all(vec));
        ans -= vec.front();
        ans -= vec.back();

        ans /= n-2;
        cout << ans << endl;
    }
}

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

int N, S;

int main(){
   while ( cin >> N && N>0){
      int M, m, addup;
      M = -1;
      m = 1001;
      addup = 0;
      for ( i = 0; i<N; i++){
         cin >> S;
         addup += S;
         if ( S > M) M = S;
         if ( S < m) m = S;
      }
   cout << (addup - M - m)/(n-2)  << endl;
   }
}

C++: #include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int n;
int x;
int main()
{
  while(cin>>n,n){
    int ans;
    double sum = 0;
    vector<int> V;
    for(int i = 0; i< n;i++){
      cin>>x;
      V.push_back(x);
    }
    sort(V.begin(),V.end());
    
    for(int i = 1;i <V.size()-1;i++){
      sum+=V[i];
    }
    ans =sum/(V.size()-2);
    cout <<ans<<endl;
  }
  return 0;
}

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

int main(){
  while( cin >> N && N > 0){ //N??????????????????????????????????????§while????????????
    int sum = 0; 
    int min = 0;
    int max = 0;
    int average = 0;

    for (int i = 0; i < N; cin >> S){
      sum += S;
      if( S > max ) max = S;
      else if(S < min) min = S; 
    }

    sum -= min + max;
    sum /= N - 2;

    //average = sum - min - max / N - 2; //???N-2?????§???????????¨?????¨??????

    cout << average << endl;
  }

  return 0;
}

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

int main() {
  while(1) {
    int n;
    std::cin >> n;
    if(n == 0)
      break;
    std::vector<int> v(n);
    for(int i = 0; i < n; i++) {
      std::cin >> v[i];
    }
    std::sort(v.begin(), v.end());
    int s = 0;
    for(int i = 1; i < n - 1; i++) {
      s += v[i];
    }
    std::cout << (s / (n - 2)) << "\n";
  }
  return 0;
}

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

typedef long long LL;
#define rep(i ,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define all(v) (v).begin(),(v).end()

typedef vector<int> vi;


int main(){
	int n;
	while (cin >> n){
		if (n == 0) break;
		vi score;
		int s;
		rep(i, n){
			cin >> s;
			score.push_back(s);
		}
		sort(all(score));
		int ans = 0;
		for (int i = 1; i < n - 1; i++){
			ans += score[i];
		}
		cout << ans / (n - 2) << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n,s[100],ans=0,tmp;
  while(1){
    ans=0;
    cin>>n;
    if(n==0) break;
    for(int i=0;i<n;i++){
      cin>>s[i];
    }
    for(int i=0;i<n;i++){
      for(int j=n-1;i<j;j--){
	if(s[j]>s[j-1]){
	  tmp=s[j-1];
	  s[j-1]=s[j];
	  s[j]=tmp;
	}
      }
    }
    for(int i=1;i<n-1;i++){
      ans+=s[i];
    }
    ans/=(n-2);
    cout<<ans<<endl;
  }
return 0;
}

C++: #include<stdio.h>

void QSort(int x[ ], int left, int right);
void Swap(int x[ ], int i, int j);

void QSort(int x[ ], int left, int right)
{
    int i, j;
    int pivot;

    i = left;                   
    j = right;                  

    pivot = x[(left + right) / 2];
    while (1) {                   

        while (x[i] < pivot)      
            i++;                  

        while (pivot < x[j])      
            j--;                  
        if (i >= j)               
            break;                

        Swap(x, i, j);            
        i++;                      
        j--;
    }

    if (left < i - 1)              
        QSort(x, left, i - 1);     
    if (j + 1 <  right)            
				QSort(x, j + 1, right);    
		}

void Swap(int x[ ], int i, int j)
{
    int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}

int main(void)
{
	int i;
	int j;
	int k;
	int n;
	int d[20];
	int p[100];
	int sum;
	int ave;
	
	while(1){

		scanf("%d",&n);
		if(n==0) 
			break;
		
		j=0;
		for(i=0;i<n;i++){
		scanf("%d",&p[i]);
		}

		QSort(p,0,n-1);	
	
		sum = 0;
		for(i=1;i<n-1;i++)
			sum += p[i];
	
			d[j] = sum / (n-2);
			j++;
	}
	
	for(k=0;k<j;k++){
		printf("%d",d[k]);
	}
	
	return 0;

C++: 
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>

#include<numeric>

#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(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int main() {
	
	int N;

	while(cin >> N && N)
	{
		vector<int> score(N,0);
		rep(i, N){
			cin >> score[i];
		}

		int max_s = *max_element(ALL(score));
		int min_s = *min_element(ALL(score));

		//dump(max_s); dump(min_s);

		rep(i,N){if(score[i]==max_s){score.erase(score.begin()+i);break;}}
		rep(i,N){if(score[i]==min_s){score.erase(score.begin()+i);break;}}
	
		//DUMP(score);

		int ave = accumulate(ALL(score),0) / score.size();
		
		cout << ave << endl;
	}

	return 0;
}

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

using namespace std;

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

    if(n == 0) break;

    unsigned int min_val = UINT32_MAX;
    unsigned int max_val = 0;
    unsigned int count = 0;
    for(unsigned int i = 0; i < n; i++){
      unsigned int val;
      cin >> val;
      min_val = min(val, min_val);
      max_val = max(val, max_val);
      count += val;
    }
    cout << (count - min_val - max_val) / (n -2) << endl;
  }
  
  return 0;
}