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

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

using namespace std;

void remove_minmax(vector<int> &data){
  int max = 0;
  int min = 1000000;
  int min_i = 0;
  int max_i = 0;
  int count = 0;
  vector<int>::iterator it = data.begin();
  while (it != data.end()){
    if (*it < min){
      min = *it;
      min_i = count;
    }
    if (*it > max){
      max = *it;
      max_i = count;
    }
    ++count;
    ++it;
  }
  data[max_i] = 0;
  data[min_i] = 0;
}

int main(void){
  int n;
  while (cin >> n){
    if (n == 0){
      return 0;
    }
    
    vector<int> data;
    
    for (int i=0; i<n; ++i){
      int num;
      cin >> num;
      data.push_back(num);
    }
    remove_minmax(data);

    int total = floor((double)accumulate(data.begin(), data.end(), 0)/(n-2));
    cout << total << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
using namespace std;

typedef vector<int> Ivec;
int main() {
	int n;
	
	while (scanf("%d", &n) != EOF) {
		if (n == 0)
			return 0;
		int Sum = 0, Max = -1, Min = 1001, num[2];
		for (int i = 0; n > i; i++) {
			int buf;
			scanf("%d", &buf);
			if (buf > Max) {
				Max = buf;
				num[0] = i;
			}
			if (buf < Min) {
				Min = buf;
				num[1] = i;
			}
			Sum += buf;
		}
		printf("%d\n", (int)((Sum - (num[0] == num[1] ? Max : Max+Min))/(n- (num[0] != num[1]) - 1)));
	}
	return 0;
}

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

int main(){
	int n, ma, mi, tmp, ans;
	while(cin >> n){
		if(n == 0) break;
		ma = 0;
		mi = 1001;
		ans = 0;
		for(int i = 0;i<n;i++){
			cin >> tmp;
			ans += tmp;
			mi = fmin(tmp,mi);
			ma = fmax(tmp,ma);
		}
		cout << int(ans - mi - ma)/(n-2) << endl;
	}
	return 0;
}

C++: #include <stdio.h>
int main(){
  int n,s,i,min=1000,max=0,sum=0,ave;
  while(1){
    scanf("%d",&n);
    if(3<=n&&n<=100){ 
      for(i=1;i<=n;i++){
     scanf("%d",&s);
      if(s<min){
    min=s;
      }
      if(s>max){
    max=s;
      }
      sum=sum+s;
   }
      sum=sum-max-min;
      ave=sum/(n-2);
      printf("%d\n",ave);
    }
    else if(n==0){
      break;
    }   
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
	int n;
	while ( cin >> n, n ) {
		int m = 10000, M = 0, sum = 0;
		for (int i = 0; i < n; ++i) {
			int v; cin >> v;
			sum += v;
			m = min(m, v);
			M = max(M, v);
		}
		cout << (sum - m - M) / (n-2) << endl;
	}
}

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

int main(){
  int a[101];
  int b[20];
  int n = 0;
  int i = 0;
  int max = 0;
  int min = 1000;
  int sum = 0;
  int counter = 0;
  while(1){
    max = 0;
    min = 1000;
    sum = 0;
    cin >> n;
    if(n==0) break;
    for(i=0;i<n;i++){
      cin >> a[i];
      if(max <= a[i]) max = a[i];
      if(min >= a[i]) min = a[i];
      sum += a[i];
    }
    b[counter] = (sum - max - min) / (n - 2);
    counter++;
  }
  for(i=0;i<counter;i++){
    cout << b[i];
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  int n, x, mx ,mn;
  int a[100] = {};
  double Sum,Sum2,Sum3;
  int Sum4;
  while(1){
    cin >> n;
    if(n == 0) break;
    for(int i=0;i<n;i++)cin >> a[i];
    mx = a[0];
    mn = a[0];
    for(int i=0;i<n;i++){
      mx = max(mx,a[i]);
      mn = min(mn,a[i]);}
    Sum = 0;
    for(int i=0;i<n;i++) Sum += a[i];
    Sum2 = Sum - mx - mn;
    Sum3 = Sum2 / (n-2);
    Sum4 = Sum3;
    cout <<  Sum4 << endl;
    for(int i =0; i<n;i++)a[i] = 0;
    

  }

  return 0;
}

C++: #include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
    int n;
    while(cin>>n,n){
        vint v(n);
        rep(i,n) cin>>v[i];
        sort(ALL(v));
        ll sum = 0;
        reep(i,1,n-1){
            sum += v[i];
        }
        cout << sum/n-2 << endl;
    }
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

C++: int maximum = 0;
for (int i=1; i<S; ++i)
    for (int j=i; j<S; ++j)
        if (tax(X,i)+tax(X,j) == S) // (*)
            maximum = max(maximum, tax(Y,i)+tax(Y,j));

C++: #include <iostream>
using namespace std;
int n;
int main(){
	while(cin>>n&&n){
		int p;
		int pmax=-10000000,pmin=1000000;
		int sum=0;
		for(int i=0;i<n;i++){
			cin>>p;
			pmax=max(p,pmax);
			pmin=min(p,pmin);
			sum+=p;
		}
		cout<<(sum-(pmax+pmin))/(n-2)<<endl;
	}
	return 0;
}

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

int main()
{
        while(true)
        {
                int n,A[100]={0};
                cin>>n;
                if(n==0) break;
                rep(i,n) cin>>A[i];
                sort(A,A+n);

                int sum=0;
                rep(i,n-2) sum+=A[i+1];
                cout<<sum/(n-2)<<endl;
        }
        return 0;
}

C++: # encodign: utf-8

while true do
    # ????°??????§???????????? (?????????0??\???1000??\???)
    max = -1
    min = 1001
    # ????¨?????????????
    sum = 0
    # n??????
    n = gets.to_i
    break if n == 0 # 0?????¨????????????
    # n?????????????????????
    n.times do
        v = gets.to_i
        min = v if v < min
        max = v if v > max
        sum += v
    end
    sum -= (min + max)
    p sum / (n-2)
end