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>
#include <cstdio>
#include <stack>
#include <queue>

#define N 128

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

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
int n;
while(1){ 
cin>>n;
if(!n) break;
vector<int> v(n);

int sum=0;
 for(int i=0;i<n;++i){
cin>>v[i];
}
sort(begin(v),end(v));
for(int i=1;i<n-1;++i){
sum+=v[i];}
cout<<sum/(n-2)<<endl;
}}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
using namespace std;
int main() {
	while (true) {
		int n = 0;
		scanf("%d", &n);
		if (n == 0) break;
		vector<int> a;
		for (int i = 0;i < n;++i) {
			int b = 0;scanf("%d",&b );
			a.push_back(b);
		}
		sort(a.begin(), a.end());
		int num = 0;
		for (int i = 0;i < n;++i) {
			num += a[i];
		}
		num -= (a[0] + a[n - 1]);
		printf("%d\n", num/(n-2));
	}
}

C++: #include <iostream>

using namespace std;

int main(int argc, char **argv)
{
	int n, max, min, s, t;
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		min = 1001;
		max = s = 0;
		for(int i = 0; i < n; i++){
			cin >> t;
			if(t < min){
				min = t;
			}
			if(max < t){
				max = t;
			}
			s += t;
		}
		
		cout << (s-min-max)/(n-2) << endl;
	}
	
	return 0;
}

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

using namespace std;

int main(){
	vector<int> array;
	int i,x,max,min,sum;
	max = 0;
	min = 1000;

	while(cin>>n){
	clear(array);
	sum=0;

	for(i=0;i<sizeof(array);i++){
		cin >> x;
		array.push_back(x);
	}
	for(i=0;i<n;i++){
		if(max<array[i]){
			max= array[i];
		}
	}
	for(i=0;i<n;i++){
		if(min>array[i]){
			min= array[i];
		}
	}
	for(i=0;i<sizeof(array);i++){
		sum += array[i];
	}
	sum = sum-max-min;
	cout << sum/sizeof(array) << endl; 
	}

}

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

using namespace std;

int main(){
  int i, n, s, sum, avg;
  vector<int> data;

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

    for(i=0; i<n; ++i){
      cin >> s;
      data.push_back(s);
    }

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

    for(i=1, sum=0; i<n-1; ++i)
      sum += data[i];

    avg = sum / (data.size()-2);

    cout << avg << endl;
    data.clear();
  }

  return 0;
}

C++: #pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
    int n;
  while(1){
   cin>>n;
   if(n==0)return 0;
   V<ll> a(n);
   ll sum=0;
   for(int i=0;i<n;i++){cin>>a[i];sum+=a[i];}
   sort(all(a));
   sum-=(a[0]+a[n-1]);
   cout<<sum/(n-2)<<endl;

  }
 
}

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

using namespace std;

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

C++: #include<iostream>
 
using namespace std;
 
int main(){
    while( true ){
        int n;
        int ma = 0;
        int mi = 1000;
        int s = 0;
        cin >> n;

        if (n == 0){
            break;
        }

        int a[n];

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

            if (a[i] < mi){
                mi = a[i]
            }
            
            if (a[i] > ma){
                ma = a[i]
            }
        }

        for(int i = 0; i < n; i++){
            s += a[i];
        }

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

    }   
    return 0; 
}

C++: #include<algorithm>
#include<iostream>
#define rep(i,a) for(int i=0;i<(a);++i)

int n;

int main()
{
	while( std::cin >> n )
	{
		int ma = 0, mi = 1001, S = 0;
	
		rep( i, n )
		{
			int a;
			std::cin >> a;
			ma = std::max( ma, a );
			mi = std::min( mi, a );
			S += a;		
		}
		
		std::cout << S-ma-mi << std::endl;
	}

	return 0;
}

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

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

using namespace std;
int main(){
	int n, max;
	int *score;

	while(1){
		cin >> n;
		if(n==0){
			break;
		}else{
			max = 0;
			score = new int[n];
			for(int i=0; i<n; i++){
				cin >> score[i];
			}
			sort(score, score+n);
			for(int i=1; i<n-1; i++){
				max += score[i];
			}
			cout << max/(n-2) << endl;

			delete [] score;
		}
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
        int n, s ;
	while (cin >> n && n > 0){
		int large = 0;
		int small = 1000;
		int sum = 0;
  		for (int i=0; i>n; ++i){
			cin >> s;
			sum = sum + s;
			if (large < s) {large = s;}
			if (small > s) {small = s;}
		}
		int ans = 0;
		ans = (sum - large - small) / (n - 2);
		cout << ans << endl ;
	}
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    while(1){
        vector<int> point;
        int n,x;
        long long sum=0;
        cin >> n;
        if(n==0)    break;
        while(n--){
            cin >> x;
            point.push_back(x);
        }
        sort(point.begin(),point.end());
        for(int i=1;i<point.size()-1;i++){
            sum+=point[i];
        }
        cout << sum/(point.size()-2) << "\n";
        point.clear();
    }
}