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
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int getAverageScore(int N, VI S){
	int min = S[0];
	int max = S[0];
	int sum = 0;
	FOR(i, 1, N){
		sum += S[i];
		if (min > S[i]){ min = S[i]; }
		if (max < S[i]){ max = S[i]; }
	}
	sum -= (min + max);
	return sum / N;
}
int main(){
	int N;
	VI S;
	while (true){
		cin >> N;
		if (N == 0){ break; }
		REP(i, N){
			cin >> S[i];
		}
		cout << getAverageScore(N, S)<<endl;
	}
	return 0;
}

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

using namespace std;

int main() {
	
	int n;
	
	while(cin >> n && n!=0) {
		
		int *A;
		int sum = 0;
		
		A = new int[n];
		
		for(int i=0;i<n;i++)
			cin >> A[i];
		
		sort(A, A+n);
		
		for(int i=1;i<n-1;i++)
			sum += A[i];
		
		cout << sum / (n - 2) << "\n";
		delete [] A;
		A = NULL;
	}

	return 0;
}

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

using namespace std;
int main(){
    int n=1;
    while (true){
        cin >> n;
        if(n==0) break;
        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-1;i++){
            sum+=a[i];
        }
        cout << sum /(n-2)<<endl;
    }
}

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

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

		cin >> n;

		if (n == 0) {
			break;
		}

		int minx = 1000;
		int maxx = 0;
		int temp;
		int sum = 0;
		int avr;

		for (int i = 0; i < n; i++) {
			cin >> temp;

			sum += temp;

			minx = min(minx, temp);
			maxx = max(maxx, temp);
		}

		if (minx == maxx) {
			sum -= minx;
			avr = sum / (n - 1);
		}
		else {
			sum -= minx;
			sum -= maxx;
			avr = sum / (n - 2);
		}

		cout << avr << endl;
	}

	return 0;
}

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

int main() {
    int count;
    while (cin >> count && count > 0) {
        int cur;
        int sum = 0;
        int maxScore = 0;
        int minScore = 1001;
        for (int i = 0; i < count; i++) {
            cin >> cur;
            sum += cur;
            maxScore = max(maxScore, cur);
            minScore = min(minScore, cur);
        }
        cout << (sum - minScore - maxScore) / (count - 2) << endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    while(N){
        int sum = 0,a;
        rep(i,0,N){
            cin >> a;
            sum += a;
        }
        cout << sum / N << endl;
        cin >> N;
    }
}

C++: #include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#include <cassert>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
#define vi vector<int>
using namespace std;
using ll = long long;

const int MAX = 1000000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

struct s{
  int p,i,r;
};

//比較関数（降順）
bool cmpP(const s &a, const s &b){
  return a.p > b.p;
}

//比較関数（昇順）
bool cmpI(const s &a, const s &b){
  return a.i < b.i;
}

int n,S;
int main()
{

  //cout << fixed << setprecision(10);
  while (cin >> n && n>0){
    int sum=0,M=0,m=1000;
    rep(i,n){
      cin >> S;
      sum += S;
      M = max(S,M);
      m = min(S,m);
    }
    cout << (sum-(M+m))/(n-2) << endl;
  }


  return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
  int n;
  int point[20], average;
  
  while(1){
    average = 0;
    cin >> n;
    if(n == 0) break;

    for(int i = 0 ; i < n ; i++){
      cin >> point[i];
    }
    sort(point, point + n);
    for(int i = 1 ; i < n - 1 ; i++){
      average += point[i];
    }
    if(n >= 3) average /= (n-2);
    cout << average << endl;
  }
  return 0;
}

C++: #include<cmath>
#include<cctype>
#include<cstdlib>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<utility>
#include<queue>

#define mp(a,b) make_pair(a,b)

using namespace std;
int main(){
  int n;
  while(cin >> n && n != 0){
    int x = 0;
    int mx = -1,mn = 1000;
    for (int i = 0; i < n; ++i){
      int tmp;
      cin >> tmp;
      x += tmp;
      mx = max(tmp,mx);
      mn = min(tmp,mn);
    }
    x -= mn;
    x -= mx;
    x /= n-2;
    cout << x << endl;
  }
  return 0;
}

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

int main(void) {
	int n, sum, max, min, ave,a,total;
	int i,num;

	for (;;) {
		sum = 0;
		min = 1000;
		max = 0;
		cin >> n;
		if (n == 0) {
			break;
		}
		for (i = 0; i < n; i++) {
			cin >> a;
			sum += a;
			if (max < a) {
				max = a;
			}
			if (min > a) {
				min = a;
			}

		}

		total = sum - max - min;
		num= n - 2;

		ave = total / num;

		cout << ave << endl;

	}

	return 0;
}