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<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
using namespace std;

typedef long long lint;

int main(){
    while(true){
        int n;
        cin >> n;
        if(n == 0){
            break;
        }
        vector<int> score(n);
        int sum = 0, ma = 0, mi = 1500;
        for(int i = 0 ; i < n ; i++){
            cin >> score[i];
            sum += score[i];
            ma = max(ma, score[i]);
            mi = min(mi, score[i]);
        }
        sum -= (ma + mi);
        cout << sum / (n - 2) << endl;
    }
    return 0;
}

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

int main() {
	int n, max, min, s;
	long sum;

	while (true) {
		cin >> n;
		sum = max = 0;
		min = 1000;

		if (n == 0)	break;

		for (int i = 0; i < n; i++) {
			cin >> s;
			if (s < min)	min = s;
			if (s > max)	max = s;
			sum += s;
		}
		sum -= (min + max);
		cout << sum / (n - 2) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while(cin >> n, n)
    {
        vector<int> v(n);
        for(int i = 0; i < n; i++) cin >> v[i];
        sort(v.begin(), v.end());
        int ans = 0;
        for(int i = 1; i < n - 1; i++)
        {
            ans += v[i];
        }
        ans /= n - 2;
        cout << ans << endl;
    }
    return 0;
}

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

int main(){
	int n;
	while(cin>>n){
		if(n==0)break;
		int a[n];
		int M=0,m=1e5;
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		int sum=0;
		for(int i=0;i<n;i++){
			M=max(a[i],M);
			m = min(a[i],m);
			sum+=a[i];
		}
		sum-=(M+m);
		cout<<sum/(n-2)<<endl;
	}
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	int n,i,s,sum;
	vi v;
	while(1){
		cin>>n;
		if(n==0)break;
		
		v.clear();
		rep(i,n){
			cin>>s;
			v.push_back(s);
		}
		sort(v.begin(),v.end());
		sum=0;
		for(i=1;i<n-1;i++){
			sum+=v[i];
		}
		cout<<sum/(n-2)<<endl;
	}
	
	
	
	
	
	
//////////////////////////////////////////////////////
return 0;}

C++: #include<iostream>
using namespace std;
int main(){
while(true){
int n;
cin >> n;
if(n == 0)return 0;
int a[n];
for(int i = 0; i < n; i++)
cin >> a[i];

int max = 0;
int min = 1000;
int sum = 0;

for(int i = 0 ; i < n ; i++){
	if(a[i] > max)
	max = a[i];
	if (a[i] < min)
	min = a[i];
	sum += a[i];
}
cout << (sum-max-min)/(n-2);

}
}

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

int n;

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

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

using namespace std;

int main(){
  int n;
  while(cin>>n){
    if(n==0)break;
    vector<int> score(n);
    for(int i=0;i<n;i++)cin>>score[i];

    vector<int>::iterator minIt = min_element(score.begin(),score.end());
    int minIndex = distance(score.begin(),minIt);
    score.erase(score.begin()+minIndex-1);

    vector<int>::iterator maxIt = max_element(score.begin(),score.end());
    int maxIndex = distance(score.begin(),maxIt);
    score.erase(score.begin()+maxIndex-1);

    int sum = accumulate(score.begin(),score.end(),0);
    cout << sum/score.size() << endl;
  }
  return 0;
}

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

using namespace std;

int main(void){

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

  return 0;
}

C++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <math.h>
#include <string.h>
#include <stack>
#include <cctype>

using namespace std;


int main(){

	while(1){
		int n,s,sum,max,min;

		cin>>n;
		if(n==0) break;

		sum=0;
		for(int i=0;i<n;i++){
			cin>>s;
			if(i==0){
				max=s,min=s;
			}
			if(s<min) min=s;
			if(s>max) max=s;
			sum+=s;
		}
		cout<<(sum-max-min)/(n-2)<<endl;
	}	

	return 0;
}

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

int main() {
    int N;
    while (1) {
        cin >> N;
        if (N == 0) break;
        vector<int> score(N);

        for (int i = 0; i < N; i++) {
            cin >> score[i];
        }
        sort(score.begin(), score.end());

        int h = 0;
        for (int i = 1; i < N - 1; i++) {
            h += score[i];
        }
        cout << h / (N - 2) << endl;
    }
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main() {
    int n,input;
    while (1){
        scanf("%d", &n);
        if (n==0){
            break;
        }
        int sum=0,max=0,min=1001;
        for (int i;i<n;i++) {
            cin >> input;
            sum = sum+input;
            if (max < input) max = input;
            if (min > input) min = input;
        }
        printf("%d\n", (sum-max-min)/(n-2));
    }
}