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 <bits/stdc++.h>
using namespace std;

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main()
{
   int n;
   while(cin>>n,n){
       vector<int> data;
       rep(i,n){
           int temp;
           cin>>temp;
           data.push_back(temp);
       }
       SORT(data);
       long ans=0;
       REP(i,1,n-1){
           ans+=data[i];
       }
       cout<<ans/(n-2)<<endl;;
   }
   return 0;
}

C++: #include <iostream>

int main()
{
    int judgeNum;
    int maxPoint = 0;
    int minimumPoint = 0;
    int pointSum = 0;

    std::cin >> judgeNum;

    int point[judgeNum];

    for(int i = 0; i < judgeNum; i++) {
        std::cin >> point[i];
        if(point[i] > maxPoint) {
            maxPoint = point[i];
        } else if (point[i] < minimumPoint) {
            minimumPoint = point[i];
        }
        pointSum += point[i];
    }

    std::cout << (pointSum - maxPoint - minimumPoint) / (judgeNum - 2) << std::endl;

    return 0;
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <tuple>
#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>

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 DECIM8  fixed<<setprecision(8) 
#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))

using namespace std;
int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    int sum=0,M=0,m=0;
    REP(i,n){
      int tmp;
      cin >> tmp;
      sum+=tmp;
      if(M<tmp) M=tmp;
      if(m>tmp) m=tmp;
    }
    cout << (sum-M-m)/(n-2) << endl;
  }
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;


int main()
{
	while (true)
	{
		int n;
		scanf("%d", &n);
		if (n == 0)return 0;
		ivec A;
		for (int i = 0; i < n; i++)
		{
			int s;
			scanf("%d", &s);
			A.push_back(s);
		}
		sort(A.begin(), A.end());
		int sum = 0;
		for (int i = 0; i < n; i++)
		{
			if (i == 0 || i == n - 1)continue;
			sum += A[i];
		}
		printf("%d\n", sum / (n - 2));
		
	}
	return 0;
}

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

using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		int table[n];
		
		for(int i=0;i<n;i++)cin>>table[i];
		sort(table,table+n);
//		cout<<table[1];
		for(int i=2;i<n-1;i++){
			table[1]+=table[i];
//			cout<<" "<<table[i];
		}
//		cout<<endl;
		cout<<table[1]/(n-2)<<endl;
	}
}

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

using namespace std;

int main(){
  //     <=          <
  //sort(Jnê, Iè);

  int n;


  while(1){
    cin >> n;

    if(n == 0) break;

    int data[1000];

    int sum = 0;

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

      cin >> data[i];
      sum += data[i];

    }
    sort(data, data+n);

    sum -= data[0];
    sum -= data[n-1];

    sum = sum / (n - 2);

    cout << sum << endl;

  }

  return 0;

}

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

#define int long long


signed main()
{
    int n;
    while(cin >> n, n) {
        vector<int> v(n);
        for(int i=0; i<n; ++i) cin >> v[i];
        sort(v);
        int sum = 0;
        for(int i=1; i<v.size()-1; ++i) sum += v[i];
        cout << sum / (v.size()-2) << endl;
    }
    return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	while(1){
		int N;
		cin>>N;
		if(N==0)
			return 0;
		int ans=0;
		int maxi=0,mini=INF;
		for(int i=0;i<N;i++){
			int s;
			cin>>s;
			ans+=s;
			maxi=max(s,maxi);
			mini=min(s,mini);
		}
		ans-=maxi+mini;
		cout<<ans/(N-2)<<endl;
	}
	return 0;
}