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

C++: #include <stdio.h>

int sumSB(int n,int s[]){

int i,re,min = s[0],max = s[0];

for(i = 0;i < n;i++){
	if(min > s[i]){
		min = s[i];
	}
	
	else if(max < s[i]){
		max = s[i];
	}
	
}

return(min + max);
}

int main(void){
	int n,i,sum = 0,score[128],ave;
	
	while(1){
		scanf("%d",&n);
		if(n == 0) break;
		
		for(i = 0;i < n;i++){
			scanf("%d"&score[i]);
			sum += score[i];
		}
		sum -= sumSB(n,score);
		
		ave = sum / (n - 2);
		
		printf("%d",ave);
	}	
		return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n;
vl ans;

int main(){
  while(cin >> n){
    if(n == 0) break;
    vl s;
    for(ll i = 0;i < n;i++){
      ll x;
      cin >> x;
      s.push_back(x);
    }
    ll x = 0;
    x = accumulate(s.begin(),s.end(),0ll);
    x -= *max_element(s.begin(),s.end());
    x -= *min_element(s.begin(),s.end());
    ans.push_back(x/(s.size()-2));
  }
  for(ll x : ans){
    cout << x << endl;
  }

}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

int main() {
    while (true) {
        Int n;
        cin >> n;
        if (n == 0) break;
        vector<Int> v(n);
        for (Int i = 0; i < n; i++) {
            cin >> v[i];
        }
        sort(all(v));
        Int sum = 0;
        for (Int i = 1; i < n - 1; i++) {
            sum += v[i];
        }
        dump(sum / (n - 2));
    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
int num;
while(true)
{
int ans = 0;
cin >> num;
if(num != 0)
{
int a[num];
for(int i = 0;i<num;i++)
{
 cin >> a[i];
}
sort(a, a + num);
for(int i=1; i<num-1;i++)
{
ans += a[i];
}
cout << ans << endl;
}
else
{
return 0;
}
}
}

C++: #include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(void){

while(true){
  int n, input; cin >> n;
  if(n == 0)     break;
  
  int max_point = 0, min_point = 1000, sum = 0;
  for(int i = 0 ; i < n ; i++){
    cin >> input;
    min_point = min(min_point , input);
    max_point = max(max_point , input);
    sum += input;
  }
  sum -= min_point + max_point;

  cout << sum / (n - 2) << endl;

}

  return 0;
}

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

using namespace std;

int main() {
	while (true) {
		int n, sum, avg;
		cin >> n;
		if (n == 0) {
			break;
		}

		sum = 0;
		int max_score = -1, min_score = 1001;
		for (int i = 0; i < n; i++) {
			int tmp;
			cin >> tmp;
			min_score = min(min_score, tmp);
			max_score = max(max_score, tmp);
			sum += tmp;
		}
		sum -= min_score + max_score;
		avg = sum / (n - 2);
		cout << avg << endl;
	}

	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n, s, t, M, m, h;
	while(1){
		cin >> n;
		if(not n) break;
		t = 0;
		M = 0;
		m = 1001;
		for (int i = 0; i < n; ++i){
			cin >> s;
			t += s;
			M = max(M, s);
			m = min(m, s);
		}
		cout << (t-M-m) / (n-2) << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;


int main()
{
	int n;
	while (scanf("%d", &n) != EOF) {
		if (n == 0)
			break;
		int sum = 0, max_s = -1, min_s = 1001;
		for (int i = 0; i < n; ++i) {
			int s;
			scanf("%d", &s);
			sum += s;
			max_s = max(max_s, s);
			min_s = min(min_s, s);
		}

		sum = sum - max_s - min_s;
		printf("%d\n", sum/(n-2));
	}

	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int a[2020];
  int x,i = 0;
  while (cin >> x){
    a[i++] = x;
  }
  void saiten(int* a,int b);
  saiten(a,0);
}
void saiten(int* a,int j){
  int max = 0, min = 1000, ave = 0; 
  if (a[j] != 0){
    for (int k = j+1; k <= j+a[j]; k++){
      if (max < a[k])
	max = a[k];
      if (min > a[k])
	min = a[k];
      ave += a[k];
    }
    ave = (ave - max - min)/(a[j]-2);
    cout << ave << endl;
    saiten(a, j+a[j]+1);
  }
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	int y[20] = { 0 };
	int max;
	int min;
	n = 1;
		int j = 0;
		while (n != 0){
			
			cin >> n;
			max = 0;
			min = 1000;
				y[j] = 0;
			for (int i = 0; i < n; i++){
				cin >> x[i];
				int x[1000] = { 0 };
				if (max < x[i]) max = x[i];
				if (min > x[i]) min = x[i];
				y[j] += x[i];
			}
			y[j] = y[j]-max - min;
			y[j] = y[j] / (n - 2);
			j++;
		}
	for (int k = 0; k < j; k++){
		cout << y[k]<< endl ;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main() {
    int N,input;
    while (1){
        cin >> N;
        if (N==0){
            break;
        }
        int sum=0,max=0,min=1001;
        for (int i;i<N;i++) {
            cin >> input;
            sum = sum+input;
            if (max < input) max = input;
            if (min > input) min = input;
        }
        printf("%d\n", (sum-max-min)/(N-2));
    }
}

C++: #include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
  int n;
  while(cin >> n,n){
    vector <ll> a(n);
    REP(i,n)
      cin >> a[i];
    sort(a.begin(),a.end());
    ll sum = 0;
    rep(i,1,a.size()-1){
      sum += a[i];
    }
    cout << sum/(n-2) << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
using namespace std;
typedef unsigned long ulong;

void solve() {
	vector<int> res;
	while (true) {
		int n;
		cin >> n;
		if (n == 0)break;

		vector<int> vec;
		for (int i = 0; i < n; i++) {
			int x;
			cin >> x;
			vec.push_back(x);
		}
		sort(vec.begin(), vec.end());
		int sum = 0;
		for (int i = 1; i < n - 1; i++)sum += vec[i];
		res.push_back(sum / (n - 2));
	}
	for (int i = 0; i < res.size(); i++)cout << res[i] << endl;
}

int main()
{
	solve();
	return 0;
}