Go: package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for {
		num := nextInt(sc)
		if num == 0 {
			break
		}

		score_list := []int{}
		for i := 0; i < num; 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))
	}
}

C++: #include<stdio.h>

int main(void)
{
	int  a,b=100000,c=-1,d,i,e=0;
	while(1){
	b=100000;c=-1;e=0;
	scanf("%d",&a);
	if(a==0)
		break;
	for(i=1; i<=a; i++){
		scanf("%d",&d);
		if(c<d)
			c=d;
		if(b>d)
			b=d;
		e+=d;
	}
	
	printf("%d\n",(e-b-c)/(a-2)); 
	}
	
	return 0;
}

C++: #include <iostream>

using namespace std;

int n, s;
int main(){
    while(cin >> n && n>0){
        int sum = 0, max=0, min=10000;
        for (int i = 0; i<n; i++){
            cin >> s;
            if (s > max){
                sum += max;
                max=s;
            }
            else{
                if (s < min){
                    if(min != 10000){
                        sum += min;
                        min=s;
                    }
                    else{
                        min=s;
                    }
                }
                else{
                    sum += s;
                }
            }
        }
        cout << sum/(n-2) << endl;
    }
}

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

int main()
{
  int n, maximum = 0, minimum = 1000, sum = 0, s;
  cin >> n;
  for(int i = 0 ; i < n; ++i){
    cin >> s;
    maximum = max(maximum, s);
    minimum = min(minimum, s);
    sum += s;
  }
  sum = sum - maximum -minimum;
  cout << sum/(n - 2) << endl;
  return 0;
}

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

C++: #include <stdio.h>
int max(int a,int b){
    if(a>b)return a;
    return b;
}
int min(int a,int b){
    if(a>b)return b;
    return a;
}
int main(){
    int n,top,bot,tot,temp;
    while(1){
        scanf("%d",&n);
        if(n==0)return 0;
        scanf("%d",&top);
        tot=bot=top;
        for(int i=1;i<n;i++){
            scanf("%d",&temp);
            tot+=temp;
            top=max(top,temp);
            bot=min(bot,temp);
        }
        printf("%d\n",(tot-top-bot)/(n-2));
    }
}

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

using namespace std;

int main(){
    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;
    }
    return 0;
}

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

int main() {
	int n;
	while(cin >> n && n){
		int ans = 0, s[10000];
		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];
		cout << ans / (n - 2) << endl;
	}
	return 0;
}

C++: #include<utility>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<deque>
#include<stack>
#include<complex>
#include<cmath>
#include<iostream>
#include<set>
#include<map>
#include<sstream>
#include<fstream>
#include<climits>
#include<chrono>
#include<random>
#include<functional>
#include<regex>

using namespace std;
typedef pair<int, int> P;
typedef long long ll;

// ??§????????°INF
const int INF = (1 << 30);
// ?¨±?????????????????
const double EPS = (1e-10);
// 2??????????????????????????????????????????
#define EQ(a,b) (abs((a)-(b)) < EPS)


int main()
{
	int n;
	while (true) {
		cin >> n;
		if (n == 0)break;
		int p = 0;
		int j;
		for (int i = 0; i < n; ++i) {
			cin >> j;
			p += j;
		}
		cout << p << endl;
	}
}

C++: #include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
#define ll long long
#define pb push_back

int main()
{
    int n,j=0;
    vector<int> x(20);

    while (1)
    {
        cin >> n;
        if (n == 0)
        {
            break;
        }
        int score;
        int sum = 0, max = 0, min = 1000;
        for (int i = 0;i<n;i++)
        {
            cin >> score;
            if(max <  score){
                max = score;
            }
            if(min > score){
                min = score;
            }
            sum += score;
        }
        sum = sum - max - min;
        // cout << sum <<  " max:" << max << " min:" << min << endl;
        x[j] = sum/(n-2);
        j++; 
    }
    for(int i=0;i<j;i++){
        cout << x[i] << endl;
    }
}

C++: #include <vector>
#include <algorithm>
#include <iostream>
#include <iomanip>
using namespace std;
typedef vector<int> VI;
#define PB push_back
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main(){
	while(1){
		int n;
		cin >> n;
		if(n==0)return 0;
		VI v;
		int s=0;
		REP(i,n){
			int tmp;
			cin >> tmp;
			v.PB(tmp);
		}
		SORT(v);
		FOR(i, 1, n-1)s+=v[i];
		cout << s/(n-2) << endl;
	}
}

C++: #include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<random>
#include<string>
typedef long long ll;
using namespace std;
int main(){
  ll N;
  ll s[1100];
  ll sum=0;
  ll t=0;
  while(t<=20){
  t++;
  cin >> N;
  for(ll i = 0; i < N; ++i){
      cin >> s[i];
  }
  sort(s,s+N);
  for(ll i = 1; i < N-1; ++i){
    sum+=s[i];
  }
  cout<<sum/(N-2)<<endl;
}
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
	int n;
	while(cin >> n, n) {
		vi v(n);
		rep(i, n) cin >> v[i];
		sort(all(v));
		int s = accumulate(v.begin() + 1, v.end() - 1, 0);
		cout << s / (n - 2) << endl;
	}
}