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++: /*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  rep(i,20){
    ll a;cin>>a;
    if(a==0) return 0;
    vector<ll> v(a);
    rep(j,a) cin>>v[j];
    sort(ALL(v));
    cout<<(Svec(v)-v[a-1]-v[0])/(a-2)<<endl;
  }
}

C++: #include<stdio.h>

void sort(int p[],int n);

void sort(int p[],int n)
{
    int i,j,temp;

    for (i = 0; i < n - 1; i++) {
        for (j = n - 1; j > i; j--) {
            if (p[j-1] > p[j]) {
                temp = p[j];
                p[j] = p[j-1];
                p[j-1] = temp;
            }
        }	
    }
}

int main(void)
{
	int i;
	int j;
	int k;
	int m;
	int n;
	int d[20];
	int p[100];
	int sum;
	int ave;
	
	while(m){

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

		sort(p,n);	
	
		sum = 0;
		for(i=1;i<n-1;i++)
			sum += p[i];
	
			j = 0;
			d[j] = sum / (n-2);
			j++;
		
		scanf("%d",&m);
	}
	
	for(k=0;k<j;k++){
		printf("%d",d[k]);
	}
	
	return 0;
}

C++: #include<iostream>
#include<algorithm>
 
using namespace std;
 
int main(){
    while( true ){
        int n;
        int ma = 0;
        int mi = 1000;
        cin >> n;

        if(n == 0){
            break;
        }

        int a[n];

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

        sort(a,a+n);

        for(int i = 2;i < n-1;i++){
            a[1] += a[i];
        }

        cout << a[1]/(n-2) << endl;
    }   
 
}

C++: #include<cstdio>

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int n,i;
  while(true){
    int num[500],max=0,min=100000000,sum=0;
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<n;i++){
      scanf("%d",&num[i]);
      if(num[i]<min)
	min=num[i];
      if(num[i]>max)
	max=num[i];
    }
    for(i=0;i<n;i++)
      sum+=num[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;
	int t[100];
	while(1){
		cin>>n;
		if(0==n){
			break;
		}
		for(int i=0;i<n;i++){
			cin>>t[i];
		}
		sort(t,t+n);
		int sum=0;
		for(int i=1;i<n-1;i++){
			sum+=t[i];
		}
		cout<<sum/(n-2)<<endl; 
		
	}
}

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

int main(){
	int n;
	int j[110];
	int max,min;
	for(;cin>>n,n!=0;){
		for(int i=0;i<n;i++){
			cin>>j[i];
		}
		max=0;
		min=2000;
		int sum=0;
		for(int i=0;i<n;i++){
			if(max<j[i])max=j[i];
			if(min>j[i])min=j[i];
			sum+=j[i];
		}
		sum-=max+min;
		cout<<sum/(n-2)<<endl;
	}
	return 0;
}

C++: #include <algorithm>
#include <iostream>
using namespace std;
int N, S;
int main() {
	while (cin >> N && N>0) {
		int sum = 0;
		int largest = 0;
		int smallest = 1001;
		for (int i=0; i<N; ++i) {
			cin >> S;
			largest = max(largest,S);
			smallest = min (smallest,S);
			sum += S;
		}
		sum = sum - largest;
		sum = sum - smallest;
		cout << sum /(N-2) << endl;
	}
	return 0;
}

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

int main() {

  while( true ) {
    long long int n, input;
    cin >> n;

    if ( n == 0 ) break;

    vector< long long int > s;

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

      cin >> input;
      s.push_back( input );

    }

    sort( s.begin(), s.end() );

    long long int ans = 0;

    for ( long long int i = 1; i < n - 1; i++ ) {

      ans += s[i];

    }

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

  }

  return 0;

}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
using namespace std;

typedef vector<int> Ivec;
int main() {
	int n;
	
	while (scanf("%d", &n) != EOF) {
		if (n == 0)
			return 0;
		int Sum = 0, Max = -1, Min = 1001, num[2];
		for (int i = 0; n > i; i++) {
			int buf;
			scanf("%d", &buf);
			if (buf > Max) {
				Max = buf;
				num[0] = i;
			}
			if (buf < Min) {
				Min = buf;
				num[1] = i;
			}
			Sum += buf;
		}
		printf("%d\n", (int)((Sum - (num[0] == num[1] ? Max : Max+Min))/(n- (num[0] != num[1]) - 1)));
	}
	return 0;
}

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

int main()
{
	int N, n, sum, largest, smallest;
	
	while(cin >> N && N>0){
		sum  = 0; largest = 0; smallest = 1000;
		for(int i = 0; i<N; i++)
		{
			cin >> n;
			sum += n;
			
			if(smallest > n){ smallest = n;}
			if(largest < n){ largest = n;}
		}
	
		cout << (sum-smallest-largest)/(N-2) << endl;
	}
}