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>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define REEP(i, N) for(ll i = N - 1; i >= 0; --i)
#define FOR(i,m,n) for(ll i = m; i < n; ++i)
#define RFOR(i,m,n) for(ll i = n - 1; i >= m; --i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define PB push_back
#define KIRIAGE(a, b) a += (b - a % b) % b // a ??? b ????????°????????§?¢???????
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;} // a / b ??\??????????°???´??°
#define sp(n) setprecision(n)
#define INF 1000000000
#define MOD 1000000007
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
int dx8[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
int main(void) {
    while(true) {
        int n;
        cin>>n;
        if(!n)return 0;
        vector<int> s(n);
        ll sum = 0;
        REP(i, n) {
            cin>>s[i];
            sum += s[i];
        }
        sort(ALL(s));
        sum -= s[0];
        sum -= s[n - 1];
        cout<<sum / (n - 2)<<endl;
    }
}

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

int main(){
  int n, s, sum, max, min;
  while(1){
    cin >> n;
    if(n == 0) break;
    sum = 0;
    max = 0;
    min = 100;
    for(int i = 0; i < n; i++){
      cin >> s;
      sum += s;
      if(max < s) max = s;
      if(min > s) min = s;
    }
    sum -= max;
    sum -= min;
    int ave = sum / (n-2);

    cout << ave << endl;
  }

  return 0;
}

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

int main(){
  int n,s[100],num,max,min,a;
  
  while(true){
    num =0;
   
  cin>>n;
  if(n == 0)break;

  cin>>s[0];
  max=s[0];
  min=s[0];
  num=s[0];

    
  for(int i=1;i<n;i++){
    cin>>s[i];
    
    if(max<s[i])max=s[i];
    if(min>s[i])min=s[i];
       
    num += s[i];
  }
  a = (num-max-min)/(n-2);

  cout<<a<<endl;
    
  }
  return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int n;
  while(cin>>n){
    if(n==0)return 0;
    vector<int>s(n);
    for(int i=0;i<n;i++)cin>>s[i];
    sort(rng(s));
    int ans=0;
    for(int i=1;i<n-1;i++)ans+=s[i];
    cout<<ans/(n-2)<<endl;
  }
  return 0;
}

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

using namespace std;

int main() {
    int n, total;
    int s[1000];
    while (true) {
        cin >> n;
        if (n == 0) {
            return 0;
        }
        for (int i=0; i<n; i++) {
            cin >> s[i];
        }
        sort(s, s+n);
        total = accumulate(s+1, s+n-1, 0);
        cout << total/(n-2) << endl;
    }
}

C++: #include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1) {
		ll n;
		cin>>n;
		if(n==0) break;
		vector<ll> s(n);
		REP(i,n) cin>>s[i];
		sort(ALL(s));
		ll sum=accumulate(ALL(s),0);
		sum-=s[0]+s[n-1];
		cout<<sum/(n-2)<<endl;
	}
}

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

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	while(true){
		int score;
		int n;
		int maxs,mins;
		vector<int> s(n);
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin>>s[i];
		}
		maxs=*max_element(s.begin(),s.end());
		mins=*min_element(s.begin(),s.end());
		for(int i=0;i<n;i++){
			score+=s[i];
		}
		cout<<(score-maxs-mins)/(n-2)<<endl;
	}
}

C++: #include <iostream>

using namespace std;

int main() {
  int n, s;
  while (true) {
    cin >> n;
    if (n == 0) break;
    int m = 1001, M = -1, sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> s;
      if (s < m) m = s;
      if (s > M) M = s;
      sum += s;
    }
    sum = sum - m - M;
    cout << sum / (n - 2) << endl;
  }
  
  return 0;
}

C++: #include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int main (){
  int N;

  while(cin >> N && N > 0){
    vector<int> score(N, 0);
    rep(i,N){
      cin >> score[i];
    }

    sort(ALL(score));

    int ave = accumulate(score.begin() + 1, score.end() - 1, 0)/ (N-2);

    cout << ave << endl;
  }

  return 0;
}

C++: #include <stdio.h>

int main(void) {
	int count;
	int point[200][2/*x,y*/];

	int n,d;

	while(1) {
		scanf( "%d", &count );
		if ( count == 0 ) { break; }
		
		int xmin,xmax,ymin,ymax;
		xmin=0, xmax=0, ymin=0, ymax=0;
		
		point[0][0]=0;
		point[0][1]=0;
		for ( int i=1; i<count; i++ ) {
			scanf("%d %d", &n, &d);

			switch ( d ) {
			case 0: //left
				point[i][0] = point[n][0]-1;
				point[i][1] = point[n][1];
				break;
			case 1: //down
				point[i][0] = point[n][0];
				point[i][1] = point[n][1]-1;
				break;
			case 2: //right
				point[i][0] = point[n][0]+1;
				point[i][1] = point[n][1];
				break;
			case 3: //up
				point[i][0] = point[n][0];
				point[i][1] = point[n][1]+1;
				break;
			}
			
			if ( xmax < point[i][0] ) { xmax = point[i][0]; }
			if ( xmin > point[i][0] ) { xmin = point[i][0]; }
			if ( ymax < point[i][1] ) { ymax = point[i][1]; }
			if ( ymin > point[i][1] ) { ymin = point[i][1]; }
		}
		
		printf("%d %d\n", xmax-xmin+1, ymax-ymin+1);
	}
	
	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
  int n=3;
  int point[20], average;
  
  while(1){
    average = 0;
    cin >> n;
    if(n == 0) break;

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