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

int main()
{
	int n;
	int ary[100];
	while (cin >> n, n)
	{
		for (int i = 0; i < n; i++) cin >> ary[i];
		int Max = *max_element(ary, ary + n);
		int Min = *min_element(ary, ary + n);
		int Sum = accumulate(ary, ary + n, 0);
		cout << (Sum - Max - Min) / (n - 2) << endl;
	}

	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long long int llint;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int,int>
#define pl pair<ll,ll>
const long double PI = acos(-1);
const long long INF = 1e15;
const ll DEP = (1LL << 50);
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
template<class T> bool chmax(T& a,T b){ if(a < b) {a = b; return true;} return false;}
template<class T> bool chmin(T& a,T b){ if(a > b) {a = b; return true;} return false;}
template<typename T>
T GCD(T x,T y){
    return y ? GCD(y,x%y) : x;
}
template<typename T>
string toString( const T &a ){
    ostringstream oss;
    oss << a;
    return oss.str();
};


/* 
void toporogical_sort(){
    for(int i = 0; i < v; i++){
        if(!In[i].size()) Q.push(i);
    }
    while(!Q.empty()){
        int t = Q.front(); 
        Q.pop();
        ans.push_back(t);
        for(int i = 0; i < Out[t].size(); i++){
            int nx = Out[t][i];
            int size = In[nx].size();
            for(int j = 0; j < size; j++){
                if(In[nx][j] == t){
                    In[nx].erase(In[nx].begin()+j);
                    break;
                }
            }
            if(!In[nx].size()) Q.push(nx);
        }
    }
}
*/

int N; 
int main(){
    while(true){
        cin >> N;
        if(N == 0) break;
        int a, mn = MM,mx = 0,ans = 0;
        for(int i = 0; i < N; i++){
            cin >> a;
            mn = min(mn,a);
            mx = max(mx,a);
            ans += a;
        }
        ans -= (mn+mx);
        ans /= (N-2);
        //cout << "ans=";
        cout << ans << endl;
    }
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

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

C++: #include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n,n)
    {
        vector<int>a(n);
        for(int i=0;i<n;i++)cin>>a[i];
        sort(a.begin(),a.end());
        int sum=0;
        for(int i=1;i<=n-2;i++)sum+=a[i];
        cout<<sum/(n-2)<<endl;
    }
}

C++: #include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int a;
	while(scanf("%d",&a),a){
		int M=0;int m=9999;
		int sum=0;
		for(int i=0;i<a;i++){
			int b;scanf("%d",&b);M=max(M,b);m=min(m,b);sum+=b;
		}
		printf("%d\n",(sum-M-m)/(a-2));
	}
}

C++: #include <iostream>
using namespace std;
int N, A[1024],Max,Min,Sum;

int main(){
 while(cin >> N && N>0){
  for (int i=0; i<N; ++i)
    cin >> A[i];
  for (int j=0; j<(N-1); ++j){
    Max=A[0];
	if(A[j+1]>A[j]) Max=A[j+1];
    }
  for (int k=0; k<(N-1); ++k){
    Min=A[0];
	if(A[k+1]<A[k]) Min=A[k+1];
	}
  for (int l=0; l<N; ++l){
    Sum += A[l];
	}
  cout<< (Sum-Max-Min)/(N-2) << endl;
  Sum=0;
  Max=0;
  Min=0;
 }
}

C++: #include <iostream>

using namespace std;

int main() {
	while (1) {
		int n;

		cin >> n;

		if (n == 0) {
			break;
		}

		int sum = 0, min = 1001, max = -1, temp;
		for (int i = 0; i < n; i++) {
			cin >> temp;

			sum += temp;

			if (min > temp) {
				min = temp;
			}
			if (max < temp) {
				max = temp;
			}
		}

		sum -= (min + max);

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

	return 0;
}

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

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

C++: #include<iostream>
#include<algorithm>
#include<functional>
#include<stack>
#include<vector>
#include<list>
#include<map>
#include<queue>
#include<cstring>
#include<deque>

//----------------------------------------
#define mrepp(i,n,x) for(int i = n-1; i >= x; i--)
#define mrep(i,n) mrepp(i,n,0)
#define repp(i,x,n) for(int i =x; i < n; i++)
#define rep(i,n) repp(i,0,n)

using namespace std;
//----------------------------------------


int main(void){
	for(int N; cin >> N && N;){
		int t[100];
		rep(i,N)
			cin >> t[i];
		sort(t,t+N);
		
		int to = 0;
		repp(i,1,N-1){
			to += t[i];
		}
		
		cout << to/(N-2) << endl;
	}
	
	return 0;
}

C++: #include <iostream>
using namespace std;
int N, S;
int main()
{
  while (cin >> N && N > 0){
    if (N<3 || N>100)
      exit (1);
    int sum = 0;
    int largest = 0;
    int smallest =1000;
    for (int i=0; i<N; ++i){
      cin >> S;
      if (S<0 || S>1000)
        exit (2);
      sum += S;
      if (largest < S)
        largest=S;
      if (smallest > S)
        smallest=S;
    }
    int average = 0;
    average = (sum - largest - smallest) / (N - 2);
    cout << "Average:";
    cout << average << endl;
  }
}

C++: #include<cmath>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cstdio>
#define rep(i,n) for(int i=0;i<n;i++)
#define fori(i,k,n) for(int i=k;i<n;i++)
using namespace std;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
const int dX[8] = { 0, 1, 1, 1, 0, -1, -1, -1 }, dY[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };



int main()
{
	int n = -1;
	cin >> n;
	while (1)
	{

		vector<int> ten;
		for (int i = 0; i < n; i++)
		{
			int x;
			cin >> x;
			ten.push_back(x);
		}
		sort(ten.begin(), ten.end());
		int poi = 0;
		for (int i = 1; i < ten.size() - 1; i++)
		{
			poi += ten[i];
		}
		cout << poi/(n-2) << endl;
		cin >> n;
		if (n==0)break;
	}
	
	




	return 0;
}

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

using namespace std;

int n;
int s[100];
vector<int> aans;

int main(){
	while(1){
		int ans = 0;
		cin >> n;
		if(n == 0) break;
		for(int i = 0;i < n;i++){
			cin >> s[i];
		}
		sort(s,s+n);
		for(int i = 1;i < n-1;i++){
			ans += s[i];
		}
		
		ans /= n-2;
		
		aans.push_back(ans);
	}
	for(int i = 0;i < aans.size();i++){
		cout << aans[i] << endl;
	}
}