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 <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);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 MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/

int n;
string s[155];
bool up=false;

void init(){
  rep(i,105)s[i]="aaa";
}

int main(){
  int n;
  int data[105];
  while(cin>>n){
    if(n==0)break;
    rep(i,n)cin>>data[i];
    sort(data,data+n);
    ll sum=0;
    for(int i=1;i<n-1;i++)sum+=data[i];
    cout<<sum/(n-2)<<endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

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

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

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

C++: //#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <utility>
using namespace std;
#define INF 100000005
#define MAX 200005

int a[1001];
int main(){
	int n, sum;
	while(cin >> n, n){
		sum = 0;
		for(int i = 0;i < n;i++){
			cin >> a[i];
			sum += a[i];
		}
		sum -= *max_element(a, a+n);
		sum -= *min_element(a, a+n);
		cout << sum/(n-2) << endl;
	}
	return 0;
}

C++: #include <iostream>

int main() {
	while (1) {
		int N;
		int s[100];
		std::cin >> N;
		if ( N == 0 ) break;
		for ( int i=0; i<N; i++ ) {
			std::cin >> s[i];
		}
		int min=s[0], max=s[0], sum=0;
		for ( int i=0; i<N; i++ ) {
			if ( min > s[i] ) min = s[i];
			if ( max < s[i] ) max = s[i];
			sum += s[i];
		}
		std::cout << (int)((sum-min-max)/(N-2)) << std::endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	while(true){
		int score;
		int n;
		int maxs,mins;
		cin>>n;
		if(n==0)break;
		vector<int> s(n);
		for(int i=0;i<n;i++){
			cin>>s[i];
		}
		maxs=*max_element(s.begin(),s.end());
		mins=*min_element(s.begin(),s.end());
		for(int i=0;i<n;i++){
			score+=s[i];
		}
		cout<<(score-maxs-mins)/(n-2)<<endl;
	}
}

C++: // AOJ 1147
#include<iostream>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main() {
  int n;
  while (cin >> n and n) {
    int sum = 0, mxm = -1e5, mnm = 1e5;
    REP(i, n) {
      int s;
      cin >> s;
   
      if (mxm < s) mxm = s;
      if (mnm > s) mnm = s;
   
      sum += s;
    }
   
    cout << (sum - mxm - mnm) / (n - 2) << endl;
  }
}

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

using namespace std;

int main() {
	int n;
	while (cin >> n && n != 0) {
		vector<int> s(n);
		for (int i = 0; i < n; ++i) cin >> s[i];

		sort(s.begin(), s.end());
		int ave = 0;
		for (int i = 1; i < n - 1; ++i) ave += s[i];
		ave /= (n - 2);
		cout << ave << endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<iostream>
#define S 20

int main(void)
{
	int a[S];
	int i;
	int n,max,min,sum=0;
	
	for(;;)
	{
		max=0, min=1000,sum=0;
		
		scanf("%d",&n);
		if(n==0) break;
		
		for(i=0; i<n; i++)
		{
			scanf("%d",&a[i]);
		}
		
		for(i=0; i<n; i++)
		{
			if(max<a[i]) max=a[i];
			if(min>a[i]) min=a[i];
		}
		
		for(i=0; i<n; i++)
		{
			sum+=a[i];
		}
		
		sum=sum-max-min;
		printf("%d\n",sum/(n-2));
	}
	
	return 0;
}

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

using namespace std;

int main(){
	int n;

	cin >> n;

	while(n != 0){
		int point[1005];
		int max = 0, min = 0;

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

		for(int i=1; i<n; i++){
			if(point[max] < point[i])
				max = i;
			else if(point[i] < point[min] )
				min = i;
		}

		point[max] = 0;
		point[min] = 0;

		int sum = 0;

		for(int i=0; i<n; i++)
			sum += point[i];

		//cout << sum << endl;

		cout << sum/(n-2) << endl;

		cin >> n;
	}

	return 0;
}

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

int main(){
	int n;
	cin>>n;
	vector<int> d(n);
	for(int i=0;i<n;i++)
		cin>>d[i];
	for(int i=0;i<10000;i++){
		bool isok=true;
		if(i<10){
			for(int j=0;j<n;j++)
				if(d[j]==i){
					isok=false;
					break;
					
				}
			if(!isok) continue;
			cout<<i<<endl;
			return 0;

		}
		else if(i<100){
			for(int j=0;j<n-1;j++)
				if(d[j]==i/10 && d[j+1]==i%10){
					isok=false;
					break;
				}
				if(!isok) continue;
				cout<<i<<endl;
				return 0;

			}
		else if(i<1000){
			for(int j=0;j<n-2;j++)
				if(d[j]==i/100 && d[j+1]==(i/10)%10&&d[j+2]==i%10){
					isok=false;
					break;
				}
				if(!isok)	continue;
				cout<<i<<endl;
				return 0;
			}
		else
			for(int j=0;j<n-3;j++){
				if(d[j]==i/1000 &&d[j+1]==(i/100)%10 &&d[j+2]==(i/10)%10 && d[j+3]==i%10){
					isok=false;
					break;
				}
				if(!isok) continue;
				cout<<i<<endl;
				return 0;
			}


	}


}

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

using namespace std;

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

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
  
  int n,score[100],sum;
  
  while(1){
    
    cin >>n;
    
    if(n == 0)break;

    sum=0;
    
    for(int i=0 ; i < n ; i++)cin >>score[i];
    
    sort(score,score+n);
    
    for(int i=1 ; i < n-1 ; i++)sum+=score[i];
    
    cout <<sum/(n-2)<<endl;
    
  }
  
  return 0;
}

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

int main(void){
	int n,m,max,min,answer;
	while(1){
		cin >> n;
		max = 0;
		min = INT_MAX;
		answer = 0;
		if (!n) break;
		for (int i=0;i< n;i++){
			cin >> m;
			if (m > max) max = m;
			else if (m < min) min = m;
			answer += m;

		}
		cout << (answer-max-min)/(n-2) << endl;

	}

	return 0;
}