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, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	for (;;) {
		int n; cin >> n;
		if (!n) break;

		vector<int> v(n);
		rep(i, 0, n) cin >> v[i];
		sort(all(v));
		int ans = 0;
		rep(i, 1, n - 1) ans += v[i];
		cout << ans / (n - 2) << endl;
	}
}

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


int main(){
	int num = 0;
	while (cin >> num){
		if (num == 0)return 0;
		vector<int> vec;
		int temp;
		while (cin >> temp){
			vec.push_back(temp);
		}
		sort(vec.begin(),vec.end());
		vec.pop_back();
		reverse(vec.begin(), vec.end());
		vec.pop_back();
		int ave = 0;
		for (int i = 0; i < vec.size(); i++)
			ave += vec[i];
		ave /= vec.size();
		cout << ave << endl;
	}
	return 0;
}

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

int n;

int main()
{
  while (cin >> n, n) {
    vector<int> v = vector<int>(n);
    for (int i = 0; i < n; i++)
      cin >> v[i];
    sort(v.begin(), v.end());

    int sum = accumulate(v.begin(), v.end(), -(v[0]+v[v.size()-1]));
    cout << (sum / (v.size()-2)) << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
bool b[33000];
int main() {	
	int n;
	while (cin >> n&&n) {
		int a=10000000, b=-100,x;
		long long sum = 0;
		for (int i = 0; i < n; i++) {
			cin >> x;
			sum += x;
			a = min(a, x);
			b = max(b, x);
		}
		sum -= a;
		sum -= b;
		double c = floor((double)sum / (double)(n - 2));
		cout << c << endl;
	}
}

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

int main() {
	while(1) {
		int n, add = 0, max = 0, min = 1000, s, avg;
		cin >> n;
		if(n == 0) break;
		for(int i = 0; i < n; i++) {
			cin >> s;
			if(s <= min) min = s;
			if(s >= max) max = s;
			add += s;
		}
		cout << (add - max - min)/ (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;
        cin>>n;
        if (n==0) break;
        vector<int> v(n,0);
        int sum=0;
        rep(i,n) {
            cin>>v[i];
            sum+=v[i];
        }
        sort(v.begin(),v.end());
        cout<<(sum-v[0]-v[n-1])/(n-2)<<endl;

    }
    return  0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int INF = 1 << 20;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main()
{
    while(true){
        int n; 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<cmath>
#include<vector>
#include<algorithm>
#include<string>
#include<utility>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    int dt[n];
    rep(i,n){
      cin>>dt[i];
    }
    int sum=0;
    sort(dt,dt+n);
    dt[0]=dt[n-1]=0;
    rep(i,n){
      sum+=dt[i];
    }
    cout<<sum/(n-2)<<endl;
  }
  return 0;
}

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 -1;
    }
    
    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 <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include<map>
#include<type_traits>
long long int D[10000];
long long int E[400000];

using namespace std;
int main() {
	long long int N;
	long long int Y = -1;
	cin >> N;
	while (N) {
		Y++;
		for (long long int i = 0; i < N; i++) {
			cin >> D[i];
		}

		sort(D, D + N);
		long long int W = 0;
		for (long long int i = 1; i < N-1; i++) {
			W += D[i];
		}
		E[Y] = W / (N-2);
		cin >> N;
		
	}

	for (long long int i = 0; i <=Y ;i++) {
		cout << E[i] << endl;
	}
	return 0;
}

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

int N;
vector<int> scores;
int judge;

int main()
{
        while(cin >> N){
                if(N==0) break;
                int sum = 0;
                for(int i=0;i<N;i++){
                        cin >> judge;
                        scores.push_back(judge);
                }

                sort(scores.begin(),scores.end());
                scores.erase(scores.begin());
                scores.erase(scores.end()-1);
                for(int i=0;i<N-2;i++){
                        sum += scores[i];
                }
                cout << sum/scores.size() << endl;
                scores.clear();
        }

        return 0;
}

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

int main() {
  int n;

  while (cin >> n, n) {
    int t[n];
    int sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> t[i];
      sum += t[i];
    }
    sort(t, t + n);
    cout << (sum - t[0] - t[n - 1]) / (n - 2) << endl;
  }
}

C++: //
//  main.cpp
//  no.1
//
//  Created by MacBook_Virgo on 2015/04/23.
//  Copyright (c) 2015??´ MacBook_Virgo. All rights reserved.
//

#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    int n;
    while(cin >> n,n!=0){
    int max,min;
    max = 0;
    min = 1000;
    int x;
    int sum = 0;
    for(int i = 0;i <n;i = i+1){
        cin >> x;
        sum = sum + x;
        if(x >max){
            max = x;}
        if(x < min){
            min = x;}
    }
    cout << (sum - max - min) / (n-2) << endl;
    }return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

int main() {
	int c[20];   // int[] c = new int[20];
	int w = 0;
	while (true)
	{
		int a;
		cin >>  a;// int a = int.Parse(Console.ReadLine());
		if (a == 0)
			break;
		int sum = 0;
		int b[a];
		for (int j = 0; j < a; j++)
		{
			cin >> b[j];
			sum += b[j];
		}
		sum -= b.Max() + b.Min();
		c[w] = (sum / (a - 2));
		w++;
	}
	for (int j = 0; j<w; j++)
	{
		cout << c[j] << endl;
	}
}