Go: package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	for n != 0 {
		arr := make([]int, n)
		for i := range arr {
			fmt.Scan(&arr[i])
		}
		sort.Ints(arr)

		sum := 0
		for i := 1; i < len(arr)-1; i++ {
			sum += arr[i]
		}
		fmt.Println(sum / (n - 2))
		fmt.Scan(&n)
	}
}

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

using namespace std;

int main(){
	int n;
	while(cin>>n,n){
		int a[n];
		for(int i=0;i<n;i++)cin>>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++: #define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for (auto &it : t) cout << it << " ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
   	int a;
   	while(1){
	cin >> a;
	if (a == 0) break;
	
	vector<int> v(a);
	for (int i = 0; i < a; i++) cin >> v[i];
	sort(all(v));
	int sum = 0;
	for (int i = 1; i < a - 1; i++) sum += v[i];
	cout << sum / (a - 2) << endl;	
  }
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}

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

using namespace std;

int main(){
	vector<int> array;
	vector<int> ans;
	int i,x,max,min,sum,n;


	while(1){
	cin>>n;
	max = 0;
	min = 1000;
	if(n==0){
		for(i=0;i<ans.size();i++){
			cout<<ans[i]<< endl;
		}

		break;
	}
	array.clear();
	sum=0;

	for(i=0;i<n;i++){
		cin >> x;
		array.push_back(x);
	}
	for(i=0;i<n;i++){
		if(max<array[i]){
			max= array[i];
		}
	}
	for(i=0;i<n;i++){
		if(min>array[i]){
			min= array[i];
		}
	}
	for(i=0;i<n;i++){
		sum += array[i];
	}
	sum = sum-max-min;
	ans.push_back(sum/(n-2));  //2ひいた分だけ割る数を減らす 
	}

}

C++: #include<iostream>
#include<algorithm>
 
using namespace std;
 
int main(){
    while( true ){
        int n;
        int ma = 0;
        int mi = 1000;
        int s = 0;
        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];
            }
            if(mi > a[i]){
                mi = a[i];
            }
            s += a[i];
        }

        cout << (s - ma - mi)/(n - 2) << endl;
    }   
 
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
  while(1){
    int n;
    cin >> n;
    if(n == 0)break;
    vector<int> array(n,0);
    int max_a = 0;
    int min_a = 10000;

    for(int i = 0;i < n;i++){
      int tmp;
      cin >> tmp;
      array[i] = tmp;
      max_a = max(max_a,tmp);
      min_a = min(min_a,tmp);

    }

    int sum = -1*(max_a + min_a);
    for(int i = 0; i < n;i++){
	sum += array[i];
    }
    cout << (int)(sum / (n-2)) << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(n==0)break;
		int point[100],sum=0;
		for(int i=0,s;i<n;++i){
			cin>>s;
			point[i]=s;
		}
		for(int i=0,s;i<n;++i){
			for(int j=i+1;j<n;++j){
				if(point[i]>point[j])swap(point[i],point[j]);
			}
		}
		for(int i=1;i<n-1;++i){
			sum+=point[i];
		}
		cout<<(sum/(n-2))<<"\n";
	}
	return 0;
}

C++: #include <stdio.h>

int max = 0;
int min = 1000;

int maximum(int s)
{
	if(max < s){ max = s; }
	
	return max;
}


int minimum(int s)
{
	if(min > s){ min = s; }
	
	return min;
}


int main(void)
{
	int n;
	int i;
	int s;
	
	while(scanf("%d", &n) != EOF){
		if(n == 0){ break; }
		int ans = 0;
		int maxi, mini;
		for(i = 0; i < n; i++){
			scanf("%d", &s);
			maxi = maximum(s);
			mini = minimum(s);
			ans += s;		
		}
		ans = (ans - maxi - mini) / (n - 2);
		printf("%d\n", ans);
		
		max = 0;
		min = 1000;
	}
	return 0;
}

C++: #include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };

int main() {
	int n;
	while (cin >> n, n){
		int sum = 0;
		int mi = 1000000000;
		int ma = 0;
		REP(i, n){
			int a;
			cin >> a;
			sum += a;
			mi = min(mi, a);
			ma = max(ma, a);
		}
		cout <<(sum-ma-mi)/(n-2) <<endl;
	}
}

C++: #include <stdio.h>

int main(void)	{
	
	int n, s, smax, smin, ssum, mean;
	
	while (true)	{
		
		scanf("%d", &n);
		
		if (n == 0)	{
			break;
		}
		
		smax = 0;
		smin = 1000;
		ssum = 0;
		
		for (int i = 1; i <= n; i++)	{
			
			scanf("%d", &s);
			
			if (smax < s)	{
				smax = s;
			}
			if (smin > s)	{
				smin = s;
			}
			
			ssum += s;
		}
		
		mean = (ssum - smax - smin) / (n - 2);
		
		printf("%d\n", mean);
	}
	
	return 0;
}

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

int main() {
	int n, data;
	while(1) {
		scanf("%d", &n);
		if (n == 0) break;
		int sum=0, max=0, min=1001;
		for (int i=0; i<n; i++) {
			scanf("%d", &data);
			sum+=data;
			if (max < data) max=data;
			if (data < min) min=data;
		}
		printf("%d\n", (sum-max-min)/(n-2));
	}
}

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

#define rep(i,n) for(int i=0; i<n; i++)

int main(){
  int n;
  while(true){
    cin>>n;
    if(n==0)break;
    int sum=0;
    vector<int> v;
    rep(i,n){
      int tmp;
      cin>>tmp;
      sum+=tmp;
      v.push_back(tmp);
    }
    sort(v.begin(), v.end());
    cout<<(sum-v[0]-v[n-1])/(n-2)<<endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int n;
    while (cin>>n,n) {
        vector<int> a(n);
        rep(i,n) cin>>a[i];
        sort(a.begin(), a.end());
        ll ans = 0;
        for (int i = 1; i < n-1; ++i) {
            ans += a[i];
        }
        cout << ans/(n-2) << endl;
    }
    return 0;
}