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<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
        int n;
        int s[117];
        int chk;
        while(1){
                scanf("%d",&n);
                if(!n)
                        break;
                for(int i=0;i<n;i++){
                        scanf("%d",&s[i]);
                }
                sort(s,s+n);
            chk=0;
                for(int j=1;j<n-1;j++)
                        chk+=s[j];
                printf("%d\n",chk/(n-2));
        }
        return 0;
}

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

using namespace std;

int n;
int s[100]={};
int count = 0;
int dai,syou;
int ans[1000]={};
int judge = 0;

int main()
{
    while(1){
        scanf("%d",&n);
        if(n == 0){
            break;
        }
        dai = 0;
        syou = 1000;
        for(int i=0;i<n;i++){
            scanf("%d",&s[i]);
            if(dai <= s[i]){
                dai = s[i];
            }
            if(syou >= s[i]){
                syou = s[i];
            }
        }
        int dai_count = 0;
        int syou_count = 0;
        for(int i=0;i<n;i++){
            if(s[i]==dai && dai_count ==0){
                dai_count=1;
                
            }else if(s[i] == syou && syou_count ==0){
                syou_count = 1;
            }else{
                ans[judge] += s[i];
            }
        }
        ans[judge] = ans[judge] / (n-2);
        
        judge++;

    }
    for(int i=0;i<judge;i++){
        cout << ans[i] << endl;
    }

    
    return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>

// this require C++11
//#include <unordered_set>
//#include <unordered_map>
//#include <random>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;

template<typename T>
ostream& operator<<(ostream& os,vector<T>& vec){
    typename vector<T>::iterator it,endit=vec.end();
    os << "[";
    for(it=vec.begin();it!=endit;it++){
        os << " " << *it << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

int solve(int N){
    int av=0,in,mn,mx;
    for(int i=0;i<N;i++){
        cin >> in;
        av+=in;
        if(i==0){
            mn=in;
            mx=in;
        }
        if(mx<in)   mx = in;
        if(mn>in)   mn = in;
    }
    return (av-mx-mn)/(N-2);
}

int main(){
    int N;
    for(;;){
        cin >> N;
        if(N==0)
            break;
        cout << solve(N) << endl;
    }
	return 0;
}

C++: #include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
#define rep(i, n) for(int i=0; i<(n); ++i)

int main(void){
    int n, tmp;
    int ans = 0;
    while(cin >> n && n) {
        vector<int> in;
        rep(i, n) {
            cin >> tmp;
            in.push_back(tmp);
        }
        sort(in.begin(), in.end());
        ans = 0;
        for(int i=1; i<n-1; ++i) ans += in[i];
        cout << ans/(n-2) << endl;
    }
}

C++: #include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
  ll N;
  ll s[1100];
  cin>>N;
  while(N){
  ll sum=0;
  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;
  cin>>N;
  }
}

C++: #include <iostream>
#include <cmath>
#include <cstring>

using namespace std;

void find_max(int data[], int N){
  int flag = -1;
  int max = 0;
  for (int i=0; i<N; ++i){
    if (max < data[i]){
      max = data[i];
      flag = i;
    }
  }
  data[flag] = 0;
}

void find_min(int data[], int N){
  int flag = -1;
  int min = 1000000;
  for (int i=0; i<N; ++i){
    if (min > data[i]){
      min = data[i];
      flag = i;
    }
  }
  data[flag] = 0;
}

int main(void){
  int n;
  while (cin >> n){
    if (n == 0){
      return -1;
    }
    
    int data[20];
    memset(data, 0, sizeof(data));
    
    for (int i=0; i<n; ++i){
      cin >> data[i];
    }
    find_min(data, n);
    find_max(data, n);
    int sum = 0;
    for (int i=0; i<n; ++i){
      sum += data[i];
    }
    int total = floor((double)sum/(n-2));
    cout << total << endl;
  }
  return 0;
}

C++: #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll M = 0;
  vvl A(21);
  while (true) {
    ll N;
    cin >> N;
    if (N == 0)
      break;
    REP(i, N) {
      ll a = 0;
      cin >> a;
      A[M].push_back(a);
    }
    M++;
  }
  REP(i, M) {
    sort(ALL(A[i]));
    ll ans = 0;
    ll N = A[i].size();
    for (ll j = 1; j < N - 1; j++) {
      ans += A[i][j];
    }
    cout << ans / (N - 2) << endl;
  }
  return 0;
}