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<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#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 MAX 20
using namespace std;

int main(void){
  while(true){
    int n;  cin >> n;
    if(n==0)  break;
    int s[MAX], sum=0;
    rep(i, n) cin >> s[i];
    sort(s, s+n);
    FOR(i, 1, n-1)  sum += s[i];
    cout << sum/(n-2) << endl;

  }
  return 0;
}

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

//#define int int64_t

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

signed main() {
	int n; 
	while (cin >> n && n) {
		V v(n); input(v);
		cout << (accumulate(all(v), 0) - *max_element(all(v)) - *min_element(all(v))) / (n - 2) << endl;
	}
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	int n;
	while (cin >> n && n) {
		vector<int> d(n);
		int sum = 0;
		for (int i = 0; i < n; ++i) cin >> d[i];
		sort(d.begin(), d.end());
		for (int i = 1; i < n - 1; ++i) sum += d[i];
		cout << sum / (n - 2) << endl;
	}
	return 0;
}

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

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    while(cin >> n, n){
        vector<int> v(n);
        for (auto &&i : v) scanf("%d", &i);
        int s = 0;
        sort(v.begin(), v.end());
        for (int i = 1; i < n-1; ++i) {
            s += v[i];
        }
        printf("%d\n", s/(n-2));
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    vector<int> a;
    while(cin>>n){
        if(n==0)break;
        a.clear();
        for(int i = 0; n > i; i++){
            int tmp;cin>>tmp;
            a.push_back(tmp);
        }
        sort(a.begin(),a.end());
        int sm = 0;
        for(int i = 1; a.size()-1 > i; i++){
            sm += a[i];
        }
        cout << sm/(n-2) << endl;
    }
}

C++: #include <iostream>

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

using namespace std;

int main(void)
{
	while(1){
		int n;
		cin >> n;
		if (n == 0){
			break;
		}
		int s, sum=0, maxi, mini;
		cin >> s;
		maxi = s;
		mini = s;
		sum += s;
		for(int i=1;i<n;i++){
			cin >> s;
			maxi = max(maxi, s);
			mini = min(mini, s);
			sum += s;
		}
		sum -= (maxi + mini);
		cout << sum/(n-2) << endl;
	}
	return 0;
}

C++: #include<iostream>

#define     MIN_POINT     0
#define     MAX_POINT     1000

using namespace std;

int main(){
	int n;

	// ループ
	cin >> n;
	while(n >= 3){
		int min = (int)(MAX_POINT), max = (int)(MIN_POINT);
		int sum = (min + max) * (-1);
		int i, buf;

		// 点数の入力・合計処理
		for(i=0;i<n;i++){
			// 入力
			cin >> buf;
			// 入力値のチェック
			if((buf < ((int)(MIN_POINT))) || (buf > ((int)(MAX_POINT)))){
				cerr << "入力された値が範囲外です" << endl;
				i--;
				continue;
			}
			// 合計値に加算
			sum += buf;
			// 最大値のチェック
			if(buf > max){
				sum += max;
				max = buf;
				sum -= max;
			}
			// 最小値のチェック
			if(buf < min){
				sum += min;
				min = buf;
				sum -= min;
			}
		}

		// 合計の表示
		cout << (sum / (n - 2)) << endl;

		// 入力
		cin >> n;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define vsort(v) sort(v.begin(),v.end())
#define asort(a,n) sort(a, a + n)
#define vi vector<int>
#define vd vector<double>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int N;
    int ans;
    int cnt;
    vi vec(20);
    while(true){
        vec.assign(20, -1);
        ans = 0;
        cnt = 0;
        cin >> N;
        if(N == 0) return 0;
        rep(i, N){
            cin >> vec[i];
        }
        vsort(vec);
        REP(i, 21 - N, 19){
            ans += vec[i];
            cnt++;
        }
        cout << (int)(ans / cnt) << endl;
    }


    return 0;
}

C++: #include <iostream>

using namespace std;

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

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

using namespace std;

int main(int, char**){
	int n;
	vector<int> ret;
	while(true){
		int n,buf;
		vector<int> scores;
		cin >> n;
		if(n == 0) break;

		for(int i = 0; i < n; ++i){
			cin >> buf;
			scores.push_back(buf);
		}
		scores.erase(max_element(scores.begin(),scores.end()));
		scores.erase(min_element(scores.begin(),scores.end()));
		ret.push_back( std::accumulate(scores.begin(), scores.end(), 0) / scores.size() );
	}

	for(int av : ret){
		cout << av << endl;
	}
	return 0;
}

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

int main(){
int num,temp;

while(1){
   cin>>num;
   if(num==0){
   break;
   }
   int min=10000000,max=0,sum=0;
   for(int i=0;i<num;i++){
   cin>>temp;
   if(min>temp)min=temp;
   if(max<temp)max=temp;
   sum+=temp;
   }
   sum=sum-max-min;
   cout<<sum/(num-2)<<endl;
}

return 0;
}

C++: #include<iostream>
 
using namespace std;
 
int main(){
 
  int n;
 
  while(cin>>n){
 
 
 
    if(n==0){
      break;
    }
    int a[n];
    int max,min;
 
    max=0;
    min=1000;
 
    for(int i=0;i<n;i++){
      cin>>a[i];
 
      if(a[i]>max){
    max=a[i];
      }
 
      if(a[i]<min){
    min=a[i];
      }
    }
 
    int sum;
 
    sum=0;
 
    for(int p=0;p<n;p++){
      sum=sum+a[p];
    }
 
    sum=sum-max-min;
 
   
 
    cout << sum/(n-2) << endl; 
 
    
 
  }
 
   
 
 
 
  return 0;
}

C++: #include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int n,a,sum,ma,mi;
  while(scanf("%d",&n),n){
    sum = 0;
    ma = 0;
    mi = 1001;
    for(int i=0;i<n;i++){
      scanf("%d",&a);
      sum += a;
      ma = max(ma,a);
      mi = min(mi,a);
    }
    sum -= ma+mi;
    printf("%d\n",sum/(n-2));
  }
  return (0);
}