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<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
using namespace std;
int main(){
int n;
while(cin>>n,n){
vector<int>in;
rep(i,n){
int tmp;
cin>>tmp;
pb(in,tmp);
}
sort(all(in));
int sum=0;
loop(i,1,in.size()-1)sum+=in[i];
cout<<(int)(sum/(n-2))<<endl;
}
}

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

using namespace std;

int main(){
	int n;
	int total;
	int ave;

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

		for(int i=0;i<n;i++){
			cin>>tmp;
			v.push_back(tmp);
		}

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

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

		total=total-(v[0]+v[n-1]);
		ave=total/(n-2);
		
		cout<<ave<<endl;
		
	}
}

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

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

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
  int n;
  int point[100], 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);
    for(int i = 1 ; i < n - 1 ; i++){
      average += point[i];
    }
    average /= (n-2);
    cout << average << endl;
  }
  return 0;
}

C++: #include <stdio.h>
 
int main(){
    int n,s[1024]={0};
        int max,min,max1,min1;
        int sum,i;
 
scanf("%d\n",&n);
 
do {
        max=0;
        min=100000;
        sum=0;
        sum=0;
    max1=0;
    min1=0;
        for (i=0;i<n;i++){
                scanf("%d\n",&s[i]);
                if(s[i]>max){
            max=s[i];
                        max1=i;
                }
                if(s[i]<min){
                        min=s[i];
            min1=i;
                }
        }
        for(i=0;i<n;i++){
                if(i!=max1&&i!=min1){
                        sum+=s[i];
                }
        }
        printf("%d\n",sum/(n-2));
        scanf("%d\n",&n);
}while (n!=0);
return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  while (true) {
    int n; cin >> n;
    if (n == 0) break;
    V<> a(n); for (int i = 0; i < n; ++i) cin >> a[i];
    sort(begin(a), end(a));
    int res = accumulate(next(begin(a)), prev(end(a)), 0) / (n - 2);
    cout << res << '\n';
  }
}

C++: gag

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

int main() {
        int i, j;
        int n;
        while (cin >> n) {
                if (n == 0) break;
                int sum = 0;
                vector<int> a(n);
                for (i = 0; i < n; i ++) {
                        cin >> a[i];
                        sum += a[i];
                }
                sort(a.begin(), a.end());
                sum -= a.front();
                sum -= a.back();
                cout << sum / (n - 2) << endl;
        }
        return 0;
}

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

int main(){
    while(1){
        int N;
        cin >> N;
        if(N==0)
            break;
        int s[111];
        for (int i = 0; i < N; i++)
            cin >> s[i];
        int M=-1, m=1111, sum = 0; // M:最大値, m:最小値
        for (int i = 0; i < N;i++){
            M = max(M, s[i]);
            m = min(m, s[i]);
            sum += s[i];
        }
        int ans = (sum - M - m) / (N - 2);
        cout << ans << endl;
    }
}

C++: #include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    while(N){
        int sum = 0,a,maxi = 0,mini = INF;
        rep(i,0,N){
            cin >> a;
            sum += a;
            maxi = max(maxi, a);
            mini = min(mini, a);
        }
        sum -= (maxi + mini);
        cout << sum / N << endl;
        cin >> N;
    }
}

C++: #include<stdio.h>

int main(){

int n;
int P[102]={};
while(1){
scasnf("%d",&n);if(n==0)break;
for(int i=0;i<n;i++)
scanf("%d",&P[i]);

int s=0;
for(int i=0;i<n;i++)
for(int j=n-1;j>i;j--)
if(P[j]>P[j-1]){int t=P[j];P[j]=P[j-1];P[j-1]=t;}

for(int i=0;i<n;i++)
if(i!=0&&i!=n-1)s+=P[i];

s=s/n;
printf("%d\n",s);
}
return 0;
}

C++: #include<iostream>
#include<algorithm>
 
using namespace std;
 
int main(){
    while( true ){
        int n;
        cin >> n;

        if(n == 0){
            break;
        }

        int a[n];

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

        sort(a,a+n);

        for(int i = 2;i < n-1;i++){
            a[1]+=a[i];
        }

        cout << a[1]/(n-2) << endl;
    }   
 
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <iomanip>
#include <functional>
using namespace std;
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

int main(int argc, char* argv[])
{
	

	while(1){
		int ans=0;
		int i=0;
		int temp=0;
		int a=0;
		int ninzu=0;
		vector <int>  s;

		cin >> ninzu;

		for(i=0;i<ninzu;i++){
			cin >> a;
			if(temp < a){
				temp = a;
			}
			s.push_back(a);
			if(a == 0)break;
		}
		sort( ALL(s) );

		for(i=1;i<s.size()-1;i++){
			if(s[i] != temp || s[i] != 0)ans+= s[i];
		}

		ans = ans / (i-1);

		cout << ans << endl;
		ans=0;

	}

    return 0;
}