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 <iostream>
using namespace std;

int main()
{
  int ave[20];
  int jsup=0;
  for(int j=0;j<20;j++)
    {
      int n;
      cin >> n;
      if(n==0)
	{
	jsup = j;
	break;
	}
      int s[100];
      int max=-1, min=1001;
      int max_i = -1, min_i=-1;
      for(int i=0;i<n;i++)
	{
	  cin >> s[i];
	  if(s[i] > max)
	    {
	      max = s[i];
	      max_i = i;
	    }
	  if(s[i] < min)
	    {
	      min = s[i];
	      min_i = i;
	    }
	  if(i == n-1 && max == min)
	    min_i = max_i+1;
	}
      int sum=0;
      for(int i=0;i<n;i++)
	{
	  if(i==max_i || i==min_i)
	    continue;
	  else
	    sum += s[i];
	}
      ave[j] = sum/(n-2);
    }
  for(int j=0;j<jsup;j++)
    {
      cout << ave[j] << endl;
    }
}

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

int main(){
    int n;

    while(!cin.eof()){
        vector<int> point;
        int data;
        int ave=0;

        cin>>n;
        for(int i=0; i<n; i++){
            cin>>data;
            point.push_back(data);
        }
        sort(point.begin(), point.end());
        for(int i=1; i<point.size()-1; i++){
            ave+=point[i];
        }
        cout<<ave/(point.size()-2)<<endl;
    }

    return 0;
}

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

using namespace std;

int n, s;
int main(){
    while(cin >> n && n>0){
        int sum = 0, max=0, min=10000 , temp;
        for (int i = 0; i<n; i++){
            cin >> s;
            if (s > max){
                sum += max;
                max=s;
            }
            else{
                if (s < min){
                    if(min != 10000){
                        sum += min;
                        min=s;
                    }
                    else{
                        min=s;
                    }
                }
                else{
                    sum += s;
                }
            }
            if (max < min){
                max = temp;
                min = max;
                max = temp;
            }
        }
        cout << sum/(n-2) << endl;
    }
}

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

int main(){
  while( cin >> N && N > 0){
    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; 
    }
    
    average = sum - min - max / N; 

    cout << average << endl;
  }

  return 0;
}

C++: 
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include<map>
#include<type_traits>
int D[1000];
int E[1000];

using namespace std;
int main() {
	int N;
	int Y = -1;
	cin >> N;
	while (N) {
		Y++;
		for (int i = 0; i < N; i++) {
			cin >> D[i];
		}

		sort(D, D + N);
		int W = 0;
		for (int i = 1; i < N-1; i++) {
			W += D[i];
		}
		E[Y] = W / (N-2);
		cin >> N;
		
	}

	for (int i = 0; i <=Y ;i++) {
		cout << E[i] << endl;
	}
	return 0;
}

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

using namespace std;

int main(void){
    int n, tmp;
    int ans = 0;
    while(cin >> n && n) {
        vector<int> in;
        for(int i=0; i<n; ++i) {
            cin >> tmp;
            in.push_back(tmp);
        }
        sort(in.begin(), in.end());
        for(int i=1; i<n-1; ++i) ans += in[i];
        cout << ans/(n-2) << endl;
    }
}

C++: #include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>

using namespace std;
int main(){
	int n;
	while(1){
		cin >> n;
		if(n == 0) break;
		int s[n], i, sum = 0, ave = 0;
		for(i = 0;i < n;i++){
			cin >> s[i];
		}
		sort(s, s+n);
		s[0] = 0;
		s[n-1] = 0;

		for(i = 0;i < n;i++){
			sum += s[i];
		}
		ave = sum / (n-2);

		cout << ave << endl;
	}
	return 0;
}

C++: #include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int s[101];

int main(void) {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        int sum = 0;
        int ma = 0, mi = INF;
        for (int i = 0; i < n; i++) {
            cin >> s[i];
            ma = max(ma, s[i]);
            mi = min(mi, s[i]);
            sum += s[i];
        }
        sum -= (ma + mi);
        cout << sum / (n-2) << endl;
    }
    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 minimum = 1e3, maximum = 0, sum = 0;
    for (int i = 0; i < n; i++) {
      int s;
      cin >> s;
      sum += s;
      minimum = min(minimum, s);
      maximum = max(maximum, s);
    }
    
    cout << (sum - minimum - maximum) / (n - 2) << '\n';
  }
}

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

using namespace std;

int main() {
    int n;
    while (true) {
        cin >> n;
        if (!n) { break; }

        vector<int> v(n);

        for (int i = 0; i < n; i++) { cin >> v[i]; }
        v.sort(v.begin(), v.end());

        int sum = 0;
        for (int i = 1; i < n-1; i++) {
            sum += v[i];
        }

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

C++: #include<iostream>
#include<cmath>
using namespace std;
int main(){
    int max, min, sum,n,x,ans;
    while(true){
        cin>>n;
        if(n!=0){
            cin>>x;
            max=x;
            min=x;
            sum=x;
            for(int i=1;i<n;i++){
                cin>>x;
                sum+=x;
                if(max<x){
                    max=x;
                }
                if(min>x){
                    min=x;
                }
            }
            ans=(sum-min-max)/(n-2);
            cout<<ans<<endl;
        }else{
            break;
        }
    }
    return 0;
}