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;

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

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

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

int n;

int main() {
  while (1) {
    scanf("%d", &n);
    if (n == 0) return 0;

    int sum = 0;
    int max_s = -1;
    int min_s = 1001;
    for (int i=0; i<n; i++) {
      int s;
      scanf("%d", &s);
      sum += s;
      max_s = max(max_s, s);
      min_s = min(min_s, s);
    }

    printf("%d\n", (sum-max_s-min_s)/(n-2));
  }
}

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

using namespace std;

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

        int max_s = 0, min_s = 1000, sum = 0;
        for(int i = 0; i < n; i++){
            int s; cin >> s;
            
            max_s = max(max_s, s);
            min_s = min(min_s, s);
            sum  += s;
        }

        cout << sum - min_s - max_s << endl;
    }

    return 0;
}

C++: #include <iostream>

int main()
{
    int n;
    while(1){
        std::cin >> n;
        if(n == 0){
            break;
        }
        int score[n];
        int sum = 0;
        int max = 0;
        int min = 1000;
        for(int i = 0; i < n; i++){
            std::cin >> score[i];
            if(max < score[i]){
                max = score[i];
            }
            if(min > score[i]){
                min = score[i];
            }
            sum += score[i];
        }
        int average;
        average = (sum - max - min) / (n - 2);
        std::cout << average << std::endl;
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;

int n;
int s[102];
void solve() {
    int mini = 10000;
    int maxi = -1;
    int ans = 0;
    rep(i, n) {
        if (s[i] < mini) mini = s[i];
        if (s[i] > maxi) maxi = s[i];
        ans += s[i];
    }
    ans -= mini;
    ans -= maxi;

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

int main() {
    while (cin >> n) {
        if (n == 0) break;
        rep(i, n) cin >> s[i];
        solve();
    }
}

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

int N;
int S[100];

int main() {
  while (cin >> N) {
    if (N == 0) break;
    for (int i=0; i<N; i++) cin >> S[i];
    sort(S, S+N);
    int s = 0;
    for (int i=1; i<N-1; i++) s += S[i];
    cout << s / (N-2) << "\n";
  }
  return 0;
}

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

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

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

int main(){
  int n, data, max,min;
  int sum;

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

  return 0;
}

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

int main() {

	int jn; //?????????????????°
	int *p;
	int score;

	while (true) {

		cin >> jn;

		if (jn == 0)
			break;

		score = 0;

		p = new int[jn];

		for (int i = 0; i < jn; i++)
			cin >> p[i];


		for (int i = 0; i < jn; i++) {

			for (int j = 0; j < jn - 1; j++) {

				if (p[j] < p[j + 1]) {
					int tmp;
					tmp = p[j];
					p[j] = p[j + 1];
					p[j + 1] = tmp;
				}

			}

		}

		for (int i = 1; i < jn - 1; i++)
			score += p[i];

		score = score / (jn - 2);

		cout << score << endl;

		delete[] p;

	}


	return 0;

}

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

int main(){
	int n1;
	cin >> n1;
	int a[n1] = { 0 };
	for (int i = 0; i < n1; i++){
		cin >> a[i];
	}
	sort(a, a + n1);
	a[0] = { 0 };
	a[n1 - 1] = { 0 };
	for (int i2 = 1; i2 < n1; i2++){
		a[0] += a[i2];
	}
	cout << a[0] / (n1 - 2) << endl;
	return 0;
}

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

int main(){
  int n,s[100],num=0,max=s[0],min=s[0];
  
  cin>>n;

  for(int j=0;j<20;j++){
  
  for(int i=0;i<n;i++){
    cin>>s[i];

    if(max<s[i])max=s[i];
    if(max>s[i])min=s[i];
       
    num += s[i];
  }
  num = (num-max-min)/n;
    cout<<num<<endl;

  }
  return 0;
}

C++: #include <cstdio>

using namespace std;

int main(){
  int min,max,sum,n,score;

  while(1){
    scanf("%d",&n);
    if(!n) break;

    max=0;min=10000;sum=0;

    for(int i=0;i<n;i++){
        scanf("%d",&score);
        if(max<score) max=score;
        if(min>score) min=score;
        sum+=score;
    }

    printf("%d\n",(score-max-min)/(n-2));
  }
    return 0;
}

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

int main(){
	int n;
	while(cin >> n,n){
		int s[100],min = 1000,max = 0,sum = 0;
		for(int i = 0; i < n; i++){
			cin >> s[i];
			sum += s[i];
			if(s[i] < min){
				min = s[i];
			}
			if(s[i] > max){
				max = s[i];
			}
		}
		sum -= min + max;
		cout << floor(double(sum/(n-2))) << endl;
	}
	return 0;
}

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

int main(){
  int flag = 1;
  int n,x;
  cin >> n;
  if(n==0) return 0;
  while(flag){
    int max = -1;
    int min = 1001;
    int sum = 0;
    for(int i=0;i<n;i++){
      cin >> x;
      if(x >= max){
        sum += max;
        max = x;
      }else if(x <= min){
        sum += min;
        min = x;
      }else sum += x;
    }
    sum -= 1000;
    sum = sum / (n - 2);
    cout << sum << endl;
    cin >> n;
    if(n == 0) flag = 0;
  }
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
  int n;
  int point[20], average;
  
  while(1){
    average = 0;
    cin >> n;
    if(n == 0) break;

    for(int i = 0 ; i < n ; i++){
      cin >> point[i];
    }
    sort(point, point + n);
    if(n >= 3){
      for(int i = 1 ; i < n - 1 ; i++){
	average += point[i];
      }
    }
    if(n >= 3) average /= (n-2);
    cout << average << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std; 
int main(){
  int n;  
  while(cin>>n){
    
    if(n==0)break;
    int a[200]={};
    int sum=0;
    for(int i=0;i<n;i++){    
      int b;
      cin>>b;
      a[i]=b;
      sum+=b;
    }
    sort(a,a+n);
    sum-=a[0];
    sum-=a[n-1];
    cout<<sum/(n-2)<<endl;
  }

  return 0;
}