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>
using namespace std;

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

C++: #include<stdio.h>
int main(void)
{
  int n;
  int i;
  for(;;){
    scanf("%d",&n);
    if(n == 0) break;
    int s[n];
    for(i=0;i<n;i++){
      scanf("%d",&s[i]);
    }
    int max;
    max =s[0];
    for(i=1;i<n;i++){
      if(max<=s[i]){max=s[i];}
    }
    int min;
    min =s[0];
    for(i=1;i<n;i++){
      if(min>=s[i]){min=s[i];}
    }
    ;
    int score=0;
    for(i=0;i<n;i++){
      score=score + s[i];
    }
    score= score - min - max;
    score= score / (n-2);
    printf("%d\n",score);
  }
   
  return 0;
}

C++: /*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp*/

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;

    while (cin>>n && n>0){
        vector<int> s;

        for (int i=0;i<n;i++){
            int tmp;

            cin>>tmp;
            s.push_back(tmp);
        }
        sort(s.begin(),s.end());
        cout<<accumulate(++s.begin(),--s.end(),0)/(n-2)<<endl;
    }
    return 0;
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	while(n != 0){
		int max, min;
		int ans,t;
		ans = 0;
		max = 0; min = 1000;
		for(int i = 0; i < n; i++){
			cin >> t;
			if(t > max) max = t;
			if(t < min) min = t;
			ans += t;
		}
		ans -= (max + min);
		ans /= n - 2;
		cout << ans << endl;
		cin >> n;
	}
	
	return 0;
}

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

using namespace std;

int main(void){
    int n, tmp;
    int ans = 0;
    while(cin >> n && n) {
        vector<int> in;
        for(int i=0; i<n; ++i) {
            cin >> tmp;
            in.push_back(tmp);
        }
        sort(in.begin(), in.end());
        for(int i=1; i<n-1; ++i) ans += in[i];
        cout << ans/(n-2) << endl;
    }
}

C++: #include <iostream>
using namespace std;
int main(){
	int n,i,t,a;
	while(cin>>n,n){
		t=0;
		for(i=0;i<n;i++)cin>>a,t+=a;
		cout<<t/n<<endl;
	}
}

C++: #include <iostream>
using namespace std;
int N, S;

int main(){
  while( cin >> N && N > 0){ //N??????????????????????????????????????§while????????????
    int sum = 0; 
    int min = 0;
    int max = 0;
    //int average = 0;

    for (int i = 0; i < N; cin >> S){
      sum += S;
      if( S > max ) max = S;
      else if(S < min) min = S; 
    }

    sum -= min + max;
    sum /= N - 2;

    //average = sum - min - max / N - 2; //???N-2?????§???????????¨?????¨??????

    cout << sum << endl;
  }

  return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<map>
#include<vector>
using namespace std;
int prime[300000];
int main() {
	int n;
	while(cin >> n,n) {
		int ans = 0;
		vector<int> data;
		for(int i = 0; i < n; i++) {
			int t;
			cin >> t;
			data.push_back(t);
			ans += t;
		}
		sort(data.begin(), data.end());
		ans = ans - data[data.size()-1] - data[0];
		cout << ans / (n - 2) << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
const ll MOD=1e9+7;
//---------------------------------------------------------------------------//
int n;
int a[10000];
int main(){
        while(1) {
                cin>>n;
                if(n==0) {
                        return 0;
                }
                for(int i=0; i<n; i++) {
                        cin>>a[i];
                }
                int sum=0;
                sort(a,n);
                for(int i=1; i<n-1; i++) {
                        sum+=a[i];
                }
                cout<<sum/(n-2)<<endl;
                n=0;
        }
}

C++: #include <iostream>
#define INF (2<<29)
using namespace std;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    for(;;){
        int a,n,s=0,max=0,min=INF;
        cin>>n;
        if(n==0) break;
        for(int i = 0; i < n; i++){
            cin>>a;
            s+=a;
            if(max<a) max=a;
            if(min>a) min=a;
        }
        cout<<(s-max-min)/n<<endl;
    }
    return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define INF 1000000000
using namespace std;
bool debug=false;

int main(){
  int n;
  int data[105];
  
  while(true){
    cin>>n;
    if(n==0)break;

    rep(i,0,n)cin>>data[i];
    sort(data,data+n);

    long long sum=0;
    rep(i,1,n-1)sum+=data[i];

    cout<<sum/(n-2)<<endl;
    
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int add(int, int);

int main() {
	int x, y, s, max, a;

	while (true) {
		int max = 0;
		cin >> x >> y >> s;

		if (x == 0 && y == 0 && s == 0)	break;

		for (int i = 1; i < s; i++) {
			for (int j = 1; j < s; j++) {
				if ((add(i, x) + add(j, x)) == s) {
					a = (add(i, y) + add(j, y));
					if (a > max)	max = a;
				}
			}
		}
		cout << max << endl;
	}

	return 0;
}

int add(int a, int t) {
	return a*(100 + t)/100;
}

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

using namespace std;

int main()
{
	int N;
	while(true){
		cin >> N;
		if(N==0){return 0;}

		int* x = new int[N];
		int sum=0;

		for(int i=0; i<N; i++){
			cin >> x[i];
			sum += x[i]; 
		}
		int* x_max = max_element(x,x+N);
		int* x_min = min_element(x,x+N);

		cout << (sum - *x_max - *x_min)/(N-2) << endl;

		delete[] x;
	}
}

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

using namespace std;

int main(){
	int n;
	while(cin >> n){
		if(n == 0) break;
		int m[n];
		for(int i = 0;i < n;i++) cin >> m[i];
		sort(m,m+n);
		cout << accumulate(m+1,m+n-1,0) / (n - 2) << endl;
	}
}

C++: #include<iostream>

using namespace std;

int n;
int score[100];
int bucket[1001] = {0};
int sum_score, ave_score;

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

void sort(){
    for(int i = 0; i < n; i++){
        bucket[score[i]]++;
    }

    for(int i=0,k=0; i < 1001;i++){
        for(int j=0; j<bucket[i]; j++){
            score[k++] = i;
        }
    }
}

void ave(){
    for(int i=1; i < n-1; i++){
        sum_score += score[i];
    }
    ave_score = sum_score/(n-2);
}

void reset(){
    sum_score = 0;
    for(int i=0;i<1001; i++){
        bucket[i] = 0;      
    }
}

int main(void){
    while(1){
        cin >> n;
        if(n == 0){
            break;
        }
        set_score();
        sort();
        ave();
        cout << ave_score << endl;
        reset();
        
    }
    return 0;
}