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 <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

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

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

int main(){
	int n;
	while(scanf("%d",&n),n){
		vector < int > vi;
		for(int i = 0; i < n; i++){
			int tmp;
			scanf("%d",&tmp);
			vi.push_back(tmp);
		}
		sort(vi.begin(),vi.end());
		double ave = 0.0;
		for(int i = 1; i < n-1 ;i++){
			ave += vi[i];
		}
		printf("%.0lf\n",floor(ave/(n-2)));
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>

#define ll long long int
#define MOD 1000000007
#define pb push_back
#define ub upper_bound
#define lb lower_bound

using namespace std;

int main(){
    int N;
    int s[101];
    while(1){
        cin >> N;
        if(N==0){
            break;
        }
        for(int i=0;i<N;i++){
            cin >> s[i];
        }
        int ans=0;
        int MAX=s[0],min=s[0];
        for(int i=0;i<N;i++){
            if(MAX<s[i]){
                MAX=s[i];
            }
            if(min>s[i]){
                min=s[i];
            }
        }
        for(int i=0;i<N;i++){
            ans+=s[i];
        }
        ans-=MAX;
        ans-=min;
        cout << ans/(N-2) << endl;
    }
    return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>

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

int main(void){
    int i,n;

    int ascore[20] = {};
    int count=0;

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

    int score[n];

    for(i=0;i<n;i++){
        scanf("%d",&score[i]);
    }

    for(i=0;i<n;i++){
        qsort(score,n,sizeof(int),qtmp);
    }

    double dave=0;
    int iave=0;

    for(i=1;i<n-1;i++){
        dave += score[i];
    }

    iave = (int)((dave / (n-2)) + 0.5);

    ascore[count] = iave;
    count++;

    }

    for(i=0;i<20;i++){
        if(ascore[i] == 0) break;
        printf("%d\n",ascore[i]);
    }

    return 0;
}

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

int main()
{
    int N, S, ans, vmax, vmin, sum, x, y;
    while(true){
        cin >> N;
        if (N == 0) break;
        cin >> x >> y;
        vmin = min(x,y);
        vmax = max(x,y);
        sum = x + y;
        
        for (int i=0; i< N - 2;i++){
            cin>>S;
            vmin = min(vmin, S);
            vmax = max(vmax, S);
            sum+=S;
        }
        sum -= (vmin+vmax);
        cout << sum / (N-2)<<endl;
    }
}

C++: #include <iostream>

using namespace std;

int main(){
	while (cin >> n && n > 0){
		int large = 0;
		int small = 1000;
		int sum = 0;
                int n, s ;
  		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 <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class T>
inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>
inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    while(true){
        int N; cin >> N;
        if(N==0) break;
        int sum=0;
        int A[N];
        rep(i,N){
            cin >> A[i];
            sum+=A[i];
        }
        sort(A,A+N);
        sum-=A[0];
        sum-=A[N-1];
        cout << sum/(N-2) << endl;
    }
}

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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {
	int result[100] = {};
	int pos = 0;
	while (1) {
		int n;
		int s[101] = {};
		int mini = 1001;
		int maxi = -1;
		int total = 0;

		cin >> n;
		if (n == 0) {
			break;
		}
		pos++;
		FOR(i, 1, n) {
			cin >> s[i];
			if (maxi < s[i]) {
				maxi = s[i];
			}
			if (mini > s[i]) {
				mini = s[i];
			}
			total += s[i];
		}
		result[pos] = (total - maxi - mini) / (n - 2);
		cout << result[pos] << endl;
	}
	FOR(i, 1, pos) {
		//cout << result[i] << endl;
	}

}

C++: #define _CRT_SECURE_NO_WARNINGS

#include<fstream>
#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;
#define no_way 100000000;


int d[400][400];


int main(int argc, char **argv){
	int n;
	vector<int> v;
	int value;
	int total = 0;

	while (cin >> n && n != 0) {
		total = 0;
		v.clear();
		for (int i = 0; i < n; i++) {
			cin >> value;
			v.push_back(value);
		}
		sort(v.begin(), v.end());

		for (int i = 1; i < n - 1; i++) {
			total += v[i];
		}
		cout << total / (n - 2) << endl;
	}

	return 0;
}