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 <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    while(true){
        int N; cin >> N;
        if(N==0) break;
        int sum=0;
        int A[N];
        rep(i,N){
            cin >> A[i];
            sum+=A[i];
        }
        sort(A,A+N);
        sum-=A[0];
        sum-=A[N-1];
        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);
		cout << result[pos] << endl;
	}
	FOR(i, 1, pos) {
		//cout << result[i] << endl;
	}

}

C++: #define _CRT_SECURE_NO_WARNINGS

#include<fstream>
#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;
#define no_way 100000000;


int d[400][400];


int main(int argc, char **argv){
	int n;
	vector<int> v;
	int value;
	int total = 0;

	while (cin >> n && n != 0) {
		total = 0;
		v.clear();
		for (int i = 0; i < n; i++) {
			cin >> value;
			v.push_back(value);
		}
		sort(v.begin(), v.end());

		for (int i = 1; i < n - 1; i++) {
			total += v[i];
		}
		cout << total / (n - 2) << endl;
	}

	return 0;
}

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

using namespace std;

typedef long long LL;
typedef vector<int>    VI;
typedef vector<bool>   VB;
typedef vector<string> VS;

#define MP make_pair
#define PB push_back
#define ALL(x)  (x).begin(),(x).end()
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int n;
VI ss;

int main(void) {
	while (1) {
		ss.clear();
		cin >> n;
		if (n == 0) break;
		rep (i, n) {
			int s;
			cin >> s;
			ss.PB(s);
		}
		sort(ALL(ss));
		int sum = 0;
		REP (i, 1, ss.size() - 1) {
			sum += ss[i];
		}
		cout << sum / (n - 2) << endl;
	}
    return 0;
}

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

using namespace std;
int main(){
  int n;
  int s[111];
  while(cin>>n){
    if(n ==0)
      break;
    for(int i = 0;i<n;i++){
      cin>>s[i];
    }
    sort(s,s+n);
    int ans = 0;
    for(int i = 1;i<n-1;i++)
      ans += s[i];

    ans /= n-2;
    cout<<ans<<endl;
  }
  return 0;


}

C++: #include<iostream>

using namespace std;

int main(){
  int n,i,p,max,min,s;

    while(1){
      cin>> n;
      if(n){}else()break;
      
      cin>> p;
      s = p;
      max = p;
      min = p;

      for(i = 0 ; i < n-1 ;i++){
          cin>> p;
          pre += p;
          if(max < p){
              max = p;
	  }
          if(min > p){
              min = p;
	  }
      }
      p = (p - max - min)/ (n-2);
      cout>> p >> endl;
  }    
  return 0;
}

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

C++: #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
template<class T> using vv=vector<vector<T> >;

int main() {
  vector<int> results;

  while (true) {
    int count;
    cin >> count;
    if (count == 0) { break; }
    vi point(count);
    for (int i = 0 ; i < count ; i++) {
      cin >> point[i];
    }
    //sort(point.begin(), point.end());
    int max_point = -1;
    int min_point = 1001;
    int ave = 0;
    for (int i = 0 ; i <= point.size()-1 ; i++) {
      ave += point[i];
      if (max_point < point[i]) {
        max_point = point[i];
      }
      if (min_point > point[i]) {
        min_point = point[i];
      }
    }
    ave -= (max_point + min_point);
    ave /= (count-2);
    results.push_back(ave);
  }

  for (int i = 0 ; i < results.size() ; i++) {
    printf("%d\n", results[i]);
  }

  return 0;
}

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

int main(){
int n;
while(cin>>n){

if(n==0){break;}
int s[10000];
int al=0;
int mx=0;
int mi=10000;

for(int i=0;i<n;i++){
cin>>s[i];
al+=s[i];
mx=max(mx,s[i]);
mi=min(mi,s[i]);
}

al=(al-mx-mi)/(n-2);
cout<<al<<endl;
}



return 0;
}

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 <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
	int size;
	while(true){
		cin >> size;
		if(size == 0){
			break;
		}
		int maxv=-1;
		int minv = 100000000;
		int sum = 0;
		for(int i=0;i<size;i++){
			int num;
			cin >> num;
			sum += num;
			minv = min(minv,num);
			maxv = max(maxv,num);
		}
		int result = (sum-minv-maxv)/(size-2);
		cout << result << endl;
	}
	return 0;
}