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())
		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 < n-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

C++: import java.util.*;

public class Main {
	public Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new aoj1147().doIt();
	}
	class aoj1147{
		void doIt(){
			while(true){
				int n = sc.nextInt();
				if(n == 0)break;
				int num[] = new int [n];
				int max = 0;
				int min = Integer.MAX_VALUE;
				int ave = 0;
				for(int i = 0;i < n;i++){
					num[i] = sc.nextInt();
					if(num[i] > max)max = num[i];
					if(num[i] < min)min = num[i];
				}
				for(int i = 0;i < n;i++){
					if(num[i] == max){
						max = Integer.MAX_VALUE;
					}else if(num[i] == min){
						min = Integer.MAX_VALUE;
					}else{
						ave = ave + num[i];
					}
				}
				ave = ave / (n - 2);
				System.out.println(ave);
			}
		}
	}
}

C++: int main()
{
    int a,b[100];
    int max=0,min=100,sum=0,result;
    for(int i=0;i<a;i++){
        cin>>b[i];
        sum+=b[i];
        if(b[i]<min){
            min=b[i];
        }
        else if(b[i]>max){
            max=b[i];
        }
    }
    result=sum-min-max;
    cout<<result;
    return 0;
}

C++: #include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    while(true){
        int n; cin >> n;
        if(n == 0) return 0;
        else{
            vector<int> Score(n);
            REP(i, n) cin >> Score[i];
            int ave = 0;
            whole(sort, Score);
            for(int i = 1; i < n - 1; i++) ave += Score[i];
            ave /= n - 2;
            cout << ave << endl;
        }
    }
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	while (cin >> n, n)
	{
		int a[100];
		for (int i = 0;i < n;i++)cin >> a[i];
		sort(a, a + n);
		int sum = 0;
		for (int i = 1;i < n - 1;i++)
		{
			sum += a[i];
		}
		cout << sum / (n - 2) << endl;
	}
}

C++: #include <iostream>

using namespace std;

int main()
{
	for(int n;cin>>n,n;){
		int x,sum=0,mx=0,mn=1000;
		for(int i=0;i<n;i++){
			cin>>x; sum+=x;
			if(x>mx) mx=x;
			if(x<mn) mn=x;
		}
		cout<<(sum-mn-mx)/(n-2)<<endl;
	}
	return 0;
}

C++: #pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    while(true){
        ll n;
        cin>>n;
        if(n==0) break;
        vll v(n);
        ll sum=0;
        ll m=LLINF,M=-LLINF;
        rep(i,n){
            cin>>v[i];
            chmax(M,v[i]);
            chmin(m,v[i]);
            sum+=v[i];
        }
        cout<<(sum-m-M)/(n-2)<<endl;
    }
    return 0;
}

C++: #include <iostream>

#define el endl
#define fd fixed

using namespace std;

int main() {
  while (1) {
    int n;
    cin >> n;
    int m = n;
    if (n == 0) break;
    int max = INT_MIN;
    int min = INT_MAX;
    int ave = 0;
    while (m--) {
      int x;
      cin >> x;
      ave += x;
      if (x < min) min = x;
      if (x > max) max = x;
    }
    ave = ave - (max + min);
    ave = ave / (n-2);
    cout << ave << el;
  }
}

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

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

int main(){
int raw,j,a[100];
while (1) {
	//cout << "????????°?????\???" << endl;
	cin >> raw;
	if (raw == 0) { break;
	}
	else {
		//cout << "?????????????§?" << endl;

		for (j = 0; j < raw; j++) { cin >> a[j]; }
		int min = a[0], max = a[0];
		for (j = 0; j < raw; j++) {
			if (a[j] < min) { min = a[j]; }	
		if (a[j] > max) { max = a[j]; }
	}
	int sum = 0;
	for (j = 0; j < raw; j++) { sum = sum+a[j]; }
	cout << (sum - min - max) / (raw - 2)<<endl;
	}
}
return 0;}

C++: #include<stdio.h>

int main(){
  int i, n, s;
  int ans = 0, maxv = 0, minv = 1000;

  scanf("%d", &n);

  int score[n];
  for (i = 0; i < n; i++) {
    scanf("%d", &s);
    if (s > maxv) {
      maxv = s;
    }
    if (s < minv) {
      minv = s;
    }

    score[i] = s;
  }

  for (i = 0; i < n; i++) {
    ans += score[i];
  }

  printf("%d\n", (ans-maxv-minv)/(n-2));
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main(void)
{

  while(1){
    int n; cin >> n;

    vector<int> array(n, 0);
    if(n == 0) break;

    int sum = 0;
    for(int i = 0; i < n; i++){
      int input; cin >> input;
      array[i] = input;
    }
   
    sort(array.begin(), array.end() );

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

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

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

C++: #include <stdio.h>
#include <algorithm>

int main(void)
{
    while(true) {
        int M=0,m=50000,n,sum=0;
        scanf("%d", &n);
        if(n==0) break;
        for(int i=0; i < n; i++)
        {
            int s;
            scanf("%d", &s);
            M = std::max(s, M);
            m = std::min(s, m);
            sum += s;
        }
        printf("%d\n", (sum-M-m)/(n-2));
    }

    return 0;

}