Go: // ICPC 得点集計ソフトウェア
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for	{
		n := nextInt(sc)
		if n == 0 { break }

		score_list := []int{}
		for i := 0; i < n; i++ {
			score_list = append(score_list, nextInt(sc))
		}

		// 最低点と最高点を取り除く (3 ≤ n ≤ 100)
		sort.Sort(sort.IntSlice(score_list))
		score_list = score_list[1:len(score_list)-1]

		// 平均点を求める
		sum := 0
		for _, score := range score_list {
			sum += score
		}
		fmt.Println(sum / len(score_list))
	}
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

C++: #include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define rFOR(i, a, b) for(int i=b-1; i>=a; i--)
#define MAX 20
using namespace std;

int main(void){
  while(true){
    int n;  cin >> n;
    if(n==0)  break;
    int s[MAX], sum=0;
    rep(i, n) cin >> s[i];
    sort(s, s+n);
    FOR(i, 1, n-1)  sum += s[i];
    cout << sum/(n-2) << endl;

  }
  return 0;
}

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

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


	}
	return 0;
}

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

int main(){
	int n; 
	while( cin >> n, n ){
		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 < s.size()-1 ; i++ ){
			sum += s[i];
		}
		cout << (sum / (s.size() - 2)) << endl;
	}
}

C++: #include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

using namespace std;


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

C++: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define CHMIN(a,b) (a) = min((a),(b))
#define CHMAX(a,b) (a) = max((a),(b))

int main()
{
    int in;
    int num;
    int ans=0;
    int point[105]={};
    while(1==1)
    {
        
        scanf("%d\n",&in);
        if(in==0)return 0;
        num=in;
        ans=0;
        REP(i,num)
        {
            scanf("%d\n",&point[i]);
            ans+=point[i];
        }
        sort(&point[0],&point[num]);
        ans-=(point[0]+point[num-1]);
        printf("%d\n",ans/(num-2));
    }
    return 0;
}

C++: #include<stdio.h>
#include<iostream>
using namespace std;
int main() {
	int a;
	while (cin >> a, a) {
		int sum=0; 
		int d;
		int f;
		int e = 0;
		for (int i = 0; i < a; i++) {
			cin >> d;
			if (i == 0) {
				f = d;
				e = d;
			}
			if (d > e) {
				e = d;
			}
			if (f > d) {
				f = d;
			}
			sum += d;
		}
		sum = sum - (e + f);
		sum = sum / (a-2);
		cout << sum << endl;
	}
}

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

int s[100];

int main(){
	int n;
	while(scanf("%d", &n),n){
		for(int i = 0; i < n; i++) scanf("%d", &s[i]);
		sort(s,s+n);
		int sum = 0;
		for(int i = 1; i < n-1; i++){
			sum += s[i];
		}
		printf("%d\n", sum/(n-2));
	}
}

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

int compare(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}

int main(void) {
	int n;
	int score[1024];

	while (true) {
		std::cin >> n;
		if (!n) break;

		for (int i = 0; i < n; i++) std::cin >> score[i];

		qsort(score, n, sizeof(int), compare);
		double sum = 0;
		for (int i = 1; i < n - 1; i++) sum += score[i];
		int ave = int(sum / (n-2));
		std::cout << ave << '\n';
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <cstring>
#include <string>
#include <sstream>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

int main(void){
    for(int n, sum = 0, ma, mi; cin >> n, n; cout << sum / (n - 2) << endl, sum = 0){
        rep(i, n){
            int s; cin >> s;
            if(!i) mi = s;
            else if(i == 1) ma = max(mi, s), mi = min(mi, s); 
            else if(s < mi) sum += mi, mi = s;
            else if(s > ma) sum += ma, ma = s;
            else sum += s;
        }
    }

    return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
bool test = true;
int num;
while(test)
{
int ans = 0;
cin >> num;
if(num != 0)
{
int a[num];
for(int i = 0;i<num;i++)
{
 cin >> a[i];
}
sort(a, a + num);
for(int i=1; i<num-1;i++)
{
ans += a[i];
}
cout << ans << endl;
}
else
{
return 0;
}
}
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define sz size()
#define pb push_back
#define mp make_pair
#define ALL(X) (X).begin(),(X).end()

using namespace std;

const int INF = 1000000000;
const double eps = 1e-8;

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

C++: #include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>

using namespace std;

#define INF 999999999

int main(){
	int n, s[100], k;
	double l, g, sum;
	double ans;
	while(1){
		cin >> n;
		if(!n) break;
		g = -1;
		l = 1001;
		sum = 0;
		for(k=0;k<n;k++){
			cin >> s[k];
			sum += s[k];
			if(g < s[k]) g = s[k];
			if(l > s[k]) l = s[k];
			//cout << g << " " << l << " " << sum << endl;
		}
		ans = (sum - l - g)/((double)n-2);
		printf("%.0f\n", ans);
	}
	return 0;
}

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

using namespace std;

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

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

using namespace std;

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