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<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
 
using namespace std;
struct edge{int from, to; ll cost;};

int main(){
    ios::sync_with_stdio(0); cin.tie(0);

    int n, p;
    vector<int> v;
    while(true){
        cin >> n;
        if(n == 0) break;
        
        rep(n){
            cin >> p;
            v.push_back(p);
        }
        sort(all(v));
        cout << accumulate(v.begin()+1, v.end()-1, 0) / (n-2) << endl;
        v.clear();
    }
}

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

using namespace std;

#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000000
#define INFL 10000000000000000LL
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

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

C++: #include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    int n;
    scanf("%d",&n);
    while(n!=0){
        vector<int> s;
        int sum=0;
        REPR(i,n-1){
            int sn;
            scanf("%d",&sn);
            s.push_back(sn);
        }
        sort(s.begin(),s.end());
        FOR(i,1,s.size()-1){
            sum=sum+s[i];
        }
        int ave=sum/(n-2);
        printf("%d\n",ave);
        scanf("%d",&n);
    }
    return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int n;
int a[111];
int main(void){
  while(cin >> n && n){
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a,a+n);
    int sum = 0;
    for(int i = 1; i < n-1; i++) sum += a[i];
    cout << sum/(n-2) << endl;
  }
}

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

using namespace std;

int main() {
	int N;
	while(cin >> N && N) {
		vector<int> tmp(N);
		int score_max = 0;
		int score_min = 1001;
		int res = 0;
		for(int i = 0; i < N; i++) {
			cin >> tmp[i];
			score_max = max(score_max, tmp[i]);
			score_min = min(score_min, tmp[i]);
			res += tmp[i];
		}
		cout << (res - (score_max+score_min))/(N-2) << endl;
	}

	return 0;
}

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

C++: # encoding: 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

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

int main() {
	while(true){
		int n;
		cin>>n;
		if(n==0) return 0;
		vector<int>v(n);
		for(int i=0;i<n;i++){
			cin>>v[i];
		}
		int sum=0;
		for(int i=0;i<n;i++){
			sum+=v[i];
		}
		sort(v.begin(),v.end());
		cout<<(sum-v[0]-v[n-1])/(n-2)<<endl;
	}
	return 0;
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include<climits>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int getAverageScore(int N, VI S){
	int min = S[0];
	int max = S[0];
	int sum = 0;
	FOR(i, 1, N){
		sum += S[i];
		if (min > S[i]){ min = S[i]; }
		if (max < S[i]){ max = S[i]; }
	}
	sum -= (min + max);
	return sum / N;
}
int main(){
	int N;
	VI S;
	int b;
	int c = INT_MAX;
	while (true){
		if (c != INT_MAX){ cout << endl; }
		cin >> N;
		if (N == 0){ break; }
		REP(i, N){
			cin >> b;
			S.push_back(b);
		}
		c = getAverageScore(N, S);
		cout << c;
		S.clear();
	}
	return 0;
}

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

using namespace std;

int main(){
  int n,s[1000];

  while(cin >> n){
    int sum;
    if(!(n)) break;
    sum = 0;
    for(int i = 0;i<n;i++) cin >> s[i],sum += s[i];
    sort(s,s+n);
    printf("%d\n",(sum - s[0] - s[n-1]) / (n-2));
  }

  return 0;
}

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

using namespace std;

const int INF = 100000000;

int main(){
	int size;
	while(cin >> size,size!=0){
		//sizeに標準入力して、その値が0でない間ループ
		//while(cin >> size,size)と書く人のほうが多い(意味は同じ)。ソースを読むときの参考に
		//scanfを使う場合はcin >> size の部分をscanfで入力するようにすればよい。
		int maxv = -INF;
		int minv = INF;
		int sum = 0;
		for(int i=0;i<size;i++){
			int num;
			cin >> num;
			sum+=num;
			maxv = max(maxv,num);
			minv = min(minv,num);
		}
		int result = (sum-minv-maxv)/(size-2);
		cout << result << endl;
	}
}