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>
using namespace std;
#include <cstdio>

int main() {
int i,n,x,y,a[20],ans;
	while(1){
		scanf("%d",&n);
		if(n == 0)break;
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
		}
		x = 0;
		y = 0;
		for(i=0;i<n;i++){
		if(a[x] < a[i])x = i;
		if(a[y] > a[i])y = i;
		}
		ans = 0;
		for(i=0;i<n;i++){
			if(i == x)continue;
			if(i == y)continue;
			ans += a[i];
		}
		ans = ans / (n-2);
		printf("%d\n",ans);
	}
	return 0;
}

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

int main(){
  int flag = 1;
  int n,x;
  cin >> n;
  if(n==0) return 0;
  while(flag){
    int max = -1;
    int min = 1001;
    int sum = 0;
    for(int i=0;i<n;i++){
      cin >> x;
      if(x >= max){
        //sum += max;
        max = x;
      }//else sum += x;
      if(x <= min){
        //sum += min;
        min = x;
      }/*else*/ sum += x;
    }
//    sum -= 1000;
    sum = sum - min - max;
    sum = sum / (n - 2);
    cout << sum << endl;
    cin >> n;
    if(n == 0) flag = 0;
  }
  return 0;
}

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

int main(){
	int num;
	int score[105];
	int max = 0;
	int min = 10000;
	int sum=0;


	while(1){
		max = 0; min = 10000; sum = 0;
		for(int i=0; i < 100; i++){score[i] = 0;}

		cin >> num;

		if(num == 0) break;

		for(int i=0; i < num; i++){
			cin >> score[i];
			if(max <= score[i]) max = score[i];
			if(score[i] <= min) min = score[i];
			sum += score[i];
		}

		sum -= max; sum -= min;

		cout << sum/(num-2) << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }

int main()
{
	vector<int>sums;
	vector<int>mis;
	vector<int>mas;
	vector<int>ns;
	while (true)
	{
		int n; cin >> n;
		if (n == 0)break;
		int tmp;
		int mi = 1000;
		int ma = 0;
		int sum = 0;
		rep(i, n)
		{
			cin >> tmp;
			chmin(mi, tmp);
			chmax(ma, tmp);
			sum += tmp;
		}
		mis.push_back(mi);
		mas.push_back(ma);
		sums.push_back(sum);
		ns.push_back(n);
	}
	rep(i, sz(sums))
	{
		int ans = (sums[i] - mis[i] - mas[i]) / (ns[i] - 2);
		co(ans);
	}
	return 0;
}

C++: #include <iostream>
#include<stdio.h>
using namespace std;
int main(void){
    int n;
   int x[21];
   while(1){
       int max=-1,min=1001;
       int S=0;
       cin>>n;
       if(n==0){
           break;
       }
       for(int i=0;i<n;i++){
            cin>>x[i];
            if(min>x[i]){
                min=x[i];
            }
            if(max<x[i]){
                max=x[i];
            }
           S=S+x[i];            
       }
       S=S-(max+min);
       int A=0;
       A=S/(n-2);
       cout<<A<<endl;
   }
   return 0;
}

C++: #include<iostream>
using namespace std;
int N, S;
int main(){
	while(cin>>N && N>0) {
		int sum=0, large=0, small=1000;
		for(int i=0;i<N;++i){
			cin>>S;
			sum+=S;
			if(large<S) large=S;
			if(small>S) small=S;
		}
		sum=sum-large-small;
		cout<<sum/(N-2)<<endl;
	}
}

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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {
	int result[100] = {};
	int pos = 0;
	while (1) {
		int n;
		int s[101] = {};
		int mini = 1001;
		int maxi = -1;
		int total = 0;

		cin >> n;
		if (n == 0) {
			break;
		}
		pos++;
		FOR(i, 1, n) {
			cin >> s[i];
			if (maxi < s[i]) {
				maxi = s[i];
			}
			if (mini > s[i]) {
				mini = s[i];
			}
			total += s[i];
		}
		result[pos] = (total - maxi - mini) / (n - 2);
	}
	FOR(i, 1, pos) {
		cout << result[i] << endl;
	}

}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <list>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>

using namespace std;

int main()
{
	int n;
	int a[100];
	int ans;

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

	

	return (0);
}

C++: #include<iostream>
using namespace std;
int main(){
while(true){
int n;
if(n == 0)return 0;
cin >> n;
int a[n];
for(int i = 0; i < n; i++)
cin >> a[i];

int max = 1000;
int min = 0;
int sum = 0;

for(int i = 0 ; i <= n ; i++){
	if(a[i] > max)
	max = a[i];
	else if (a[i] < min)
	min = a[i];
	sum += a[i];
}
cout << (sum-max-min)/(n-2);

}
}

C++: #include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define all(c) begin(c),end(c)
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
using ll = long long;
using vi = vector<int>; using vs = vector<string>;
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

void solve()
{
	int N;
	while (cin >> N, N) {
		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];
		}
		sum /= (N - 2);
		cout << sum << endl;
	}
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}

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

int main()
{
	int a;
	while(scanf("%d",&a)&&a!=0)
	{
		int sum=0;
		int min=1000;
		int max=0;
		for(int i=0;i<a;i++)
		{
			int tmp;
			scanf("%d",&tmp);
			sum+=tmp;
			if(min>tmp) min = tmp;
			if(max<tmp) max = tmp;
		}	
		printf("%d\n",(sum-min-max)/(a-2));
	}
	return 0;
}

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

int main(){
	int n,s,min,max,sum;

	while(cin>>n && n>0){
		max=0;
		sum=0;
		for(int i=0;i<n;i++){
			cin>>s;
			sum+=s;
			if(i==0) min=s;
			if(s>max) max=s;
			if(s<min) min=s;
		}
		cout<<(sum-max-min)/(n-2)<<endl;
	}
}

C++: #include <iostream>

using namespace std;

int main() {
    int scores[7];
    int score_length = 0;
    
    int number = 0;
    cin>>number;
    while (number != 0) {
        int max = 0;
        int min = 1000;
        int score = 0;
        int total = 0;
        for (int i = 0; i < number; i++) {
            cin>>score;
            total += score;
            if (score > max) max = score;
            if (score < min) min = score;
        }
        total -= max + min;
        scores[score_length] = total / (number-2);
        score_length++;

        cin>>number;
    }

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