Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var (
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	for sc.Scan() {
		n, _ := strconv.Atoi(sc.Text())
		if n == 0 {
			break
		}
		scores := make([]int, n, n)
		for i := 0; i < n; i++ {
			sc.Scan()
			scores[i], _ = strconv.Atoi(sc.Text())
		}
		sort.IntSlice(scores).Sort()
		var sum = 0
		for i := 1; i < len(scores)-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

int main() {
	int n;

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

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

int main(){
  while(true){
    int njudge = 0;
    cin >> njudge;
    if(njudge == 0)return 0;
    int max=0;
    int min=10000;
    int ave=0;
    int sum=0;
    for(int i = 0 ; i<njudge ; i++){
      int input;
      cin >> input;
      if(max < input)max = input;
      if(min > input)min = input;
      sum += input;
    }
    sum -= min;
    sum -= max;
    njudge -= 2;
    ave = sum/njudge;
    cout << ave << endl;
  }
  return 0;
}

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

int main() {
  for(int n; cin >> n && n; ) {
    vector<int> s(n);
    for(int i = 0; i < n; ++i) cin >> s[i];
    sort(s.begin(), s.end());
    cout << accumulate(s.begin()+1, s.end()-1, 0) / (n-2) << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
int num;
while(true)
{
int ans = 0;
cin >> num;
if(num != 0)
{
int a[num];
for(int i = 0;i<num;i++)
{
 cin >> a[i];
}
sort(a, a + num);
for(int i=1; i<num-1;i++)
{
ans += a[i];
}
cout << ans / (num - 2) << endl;
}
else
{
return 0;
}
}
}

C++: #include <stdio.h>

int n;	//審判数
int sum;
int max;
int min;
	
void fun_max(int i, int j);
void fun_min(int i, int j);
	
int main()
{
	scanf("%d", &n);
	//printf("n=%d", n);
	
	while (n)
	{
		int i;
	
		sum = 0;
		max = -1;
		min = 1500;
		
		for (i=0; i<n; i++)
		{
			int input;
			
			scanf("%d", &input);
			//printf("input=%d\n", input);
			fun_max(max, input);
			//printf("max=%d\n", max);
			fun_min(min, input);
			//printf("min=%d\n", min);
			sum += input;
		}
		sum -= max;
		sum -= min;
		
		int ans;
		ans = sum/(n-2);
		printf("%d\n", ans);
		//printf("\n\n\n\n");
		
		scanf("%d", &n);
	}
	
	return 0;
}

void fun_max(int i, int j)
{
	if (i > j)
	{
		max = i;
	}
	else
	{
		max = j;
	}
	return;
}

void fun_min(int i, int j)
{
	if (i < j)
	{
		min = i;
	}
	else
	{
		min = j;
	}
	return;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
using namespace std;

int main(){
	int N,S;
	while(cin>>N,N){
		int sum=0,min_=INT_MAX,max_=INT_MIN;
		for(int i=0;i<N;i++){
			cin>>S;
			min_ = min(min_,S);
			max_ = max(max_,S);
			sum += S;
		}
		printf("\t%d\n",(sum-min_-max_)/(N-2));
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
while(true){
int n;
if(n == 0)return 0;
cin >> n;
int a[n];
for(int i = 0; i < n; i++)
cin >> a[i];

int max = 0;
int min = 1000;
int sum = 0;

for(int i = 0 ; i <= n ; i++){
	if(a[i] > max)
	max = a[i];
	else if (a[i] < min)
	min = a[i];
	sum += a[i];
}
cout << (sum-max-min)/(n-2);

}
}

C++: #include <cstdio>

int main()
{
  int n;

  for(;;)
    {
      int j,min=1001,max=-1,sum=0;

      scanf("%d",&n);
      if(n==0) break;

      for(int i=0;i<n;i++){
	scanf("%d",&j);
	if(j<min) min=j;
	if(j>max) max=j;
	sum += j;
      }

      printf("%d\n",(sum-min-max)/(n-2));
    }
  
}

C++: #include <iostream>

int main(){
  while(1){
    int n;
    std::cin>>n;
    if(n==0)break;
    int maxs=-1,mins=1001;
    int sum=0;
    for(int i=0;i<n;++i){
      int s;
      std::cin>>s;
      if(maxs<s) maxs=s;
      if(mins>s) mins=s;
      sum += s;
    }
    std::cout<<(sum-mins-maxs)/(n-2)<<std::endl;
  }
  return 0;
}

C++: #include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)

typedef long long ll;

int main(void) {
    int n;
    while (cin>>n && n){
        int sum=0 , h=0 , l=1000;
        REP(i,n){
            int s;
            cin >> s;
            sum+=s;
            h = max(h,s);
            l = min(l,s);
        }
        sum -= h+l;
        cout << sum/(n-2) << endl;
    }
    
    return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define PII pair<int,int>
#define PCC pair<char,char>
#define PCI pair<char,int>
#define PIC pair<int,char>
#define MP make_pair
#define DEBUG(x) cout<<#x<<": "<<x<<endl;

int main()
{
	int n;
	for (; cin >> n, n != 0;)
	{
		int Min = INF;
		int Max = -1;
		int sum = 0;
		REP(i, n)
		{
			int temp;
			cin >> temp;
			Min = min(Min, temp);
			Max = max(Max, temp);
			sum += temp;
		}
		sum =sum - Min - Max;
		int ans = sum / (n-2);
		cout <<ans<< endl;
	}
	return 0;
}

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

int main()
{
int n;
vector<int> s;
scanf("%d", &n);
s.resize(n);
for(int i = 0; i < n; ++i)
scanf("%d", &s[i]);
sort(s.begin(), s.end());
int sum = 0;
for(int i = 1; i < n - 1; ++i)
sum += s[i];
printf("%d\n", sum / (n - 2));
return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
 
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}
void pv(vector<int>&v){
	for(int i = 0;i<v.size();i++){
		if(i)cout<<' ';
		cout<<v[i];
	}
	cout<<endl;
}



signed main()
{
	//IOS();
	int N;
	vector<int>ans;
	while(cin>>N){
		if(N==0)break;
		int ma = -INF,mi = INF,sum = 0;
		rep(i,0,N){
			int t;
			cin>>t;
			chmin(mi,t);
			chmax(ma,t);
			sum+=t;
		}
		ans.push_back((sum-mi-ma)/(N-2));
	}
	for(auto e:ans){
		cout<<e<<endl;
	}
}