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<vector>
#include<algorithm>
using namespace std;

int main(){
    int N;
    vector<int> ans;

    while(cin>>N,N!=0){
        vector<int> point(N);
        for(int &i : point) cin>>i;

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

        int ave = 0;

        for(int i = 1; i < N-1;i++) ave += point[i];

        ans.push_back(ave/(N-2));
    }

    for(int i:ans) cout<<i<<endl;

}

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

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

C++: #include<iostream>

int mein() {

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

int main(){
    register int n,i;
    while(cin >> n,n){
		register int p;
        register int min = 1000;
        register int max = 0;
		register int total = 0;
		for(int i=0;i<n;i++){
			cin >> p;
			if(p > max) max = p;
			if(p < min) min = p;
			total += p;
        }
        cout << (total-max-min)/(n-2) << "\n";
    }
}

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

// macro
using ll = long long;

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

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

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

C++: #include<stdio.h>
int main(void)
{
  int n;
  int i;
  for(;;){
    scanf("%d",&n);
    if(n == 0) break;
    int s[n];
    for(i=0;i<n;i++){
      scanf("%d",&s[i]);
    }
    int max;
    max =s[0];
    for(i=1;i<n;i++){
      if(max<=s[i]){max=s[i];}
    }
    int min;
    min =s[0];
    for(i=1;i<n;i++){
      if(min>=s[i]){min=s[i];}
    }
    ;
    int score=0;
    for(i=0;i<n;i++){
      score=score + s[i];
    }
    score= score - min - max;
    score= score / (n-2);
    printf("%d\n",score);
  }
   
  return 0;
}

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

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;

    while (cin>>n && n>0){
        vector<int> s;

        for (int i=0;i<n;i++){
            int tmp;

            cin>>tmp;
            s.push_back(tmp);
        }
        sort(s.begin(),s.end());
        cout<<accumulate(++s.begin(),--s.end(),0)/(n-2)<<endl;
    }
    return 0;
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	while(n != 0){
		int max, min;
		int ans,t;
		ans = 0;
		max = 0; min = 1000;
		for(int i = 0; i < n; i++){
			cin >> t;
			if(t > max) max = t;
			if(t < min) min = t;
			ans += t;
		}
		ans -= (max + min);
		ans /= n - 2;
		cout << ans << endl;
		cin >> n;
	}
	
	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>
using namespace std;
int main(){
	int n,i,t,a;
	while(cin>>n,n){
		t=0;
		for(i=0;i<n;i++)cin>>a,t+=a;
		cout<<t/n<<endl;
	}
}

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 << sum << endl;
  }

  return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<map>
#include<vector>
using namespace std;
int prime[300000];
int main() {
	int n;
	while(cin >> n,n) {
		int ans = 0;
		vector<int> data;
		for(int i = 0; i < n; i++) {
			int t;
			cin >> t;
			data.push_back(t);
			ans += t;
		}
		sort(data.begin(), data.end());
		ans = ans - data[data.size()-1] - data[0];
		cout << ans / (n - 2) << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
const ll MOD=1e9+7;
//---------------------------------------------------------------------------//
int n;
int a[10000];
int main(){
        while(1) {
                cin>>n;
                if(n==0) {
                        return 0;
                }
                for(int i=0; i<n; i++) {
                        cin>>a[i];
                }
                int sum=0;
                sort(a,n);
                for(int i=1; i<n-1; i++) {
                        sum+=a[i];
                }
                cout<<sum/(n-2)<<endl;
                n=0;
        }
}

C++: #include <iostream>
#define INF (2<<29)
using namespace std;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    for(;;){
        int a,n,s=0,max=0,min=INF;
        cin>>n;
        if(n==0) break;
        for(int i = 0; i < n; i++){
            cin>>a;
            s+=a;
            if(max<a) max=a;
            if(min>a) min=a;
        }
        cout<<(s-max-min)/n<<endl;
    }
    return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define INF 1000000000
using namespace std;
bool debug=false;

int main(){
  int n;
  int data[105];
  
  while(true){
    cin>>n;
    if(n==0)break;

    rep(i,0,n)cin>>data[i];
    sort(data,data+n);

    long long sum=0;
    rep(i,1,n-1)sum+=data[i];

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