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 <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, num[110];

int main(){
	while (cin >> n&&n){
		REP(i, 110)num[i] = 0;
		int sum = 0;
		REP(i, n){
			cin >> num[i];
			sum += num[i];
		}
		sort(num, num + n);
		sum -= num[0] + num[n - 1];
		cout << sum / (n - 2) << endl;
	}
}

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

//constant
const int inf=1<<28;

//variable
int n;
int in;
int maxi=-inf;
int mini=inf;
int sum;


int main(){

    while(cin>>n, n){
        sum=0;
        maxi=-inf;
        mini=inf;
        for(int i=0; i<n; i++){
            cin>>in;
            maxi=max(in,maxi);
            mini=min(in,mini);
            sum+=in;
        }
        //out<<maxi<<' '<<mini<<endl;
        cout<<(int)(((sum-maxi-mini)*1.0)/(n-2))<<endl;
    }

    return 0;
}

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

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

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

#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)

int n, score[100];

void solve() {
  rep(i,n) cin>>score[i];

  sort(score, score+n);
  double sum = 0;
  REP(i,1,n-1) sum += score[i];
  
  cout<<(int)(sum/(n-2))<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>n, n) {
    solve();
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;

void merge (int *first1, int *last1, int *first2, int *last2){
    int size1 = last1 - first1;
    int size2 = last2 - first2;
    int *result = new int[size1+size2];
    int i = 0;
    int j = 0;
    int index = 0;
    while (true){
        if (i < size1 && (first1[i] <= first2[j] || j >= size2)){
            result[index] = first1[i];
            ++i; ++index;
        }
        if (j < size2 && (first1[i] > first2[j] || i >= size1)){
            result[index] = first2[j];
            ++j; ++index;
        }
        if (i==size1 && j==size2){
            for (i=0; i<size1; ++i) first1[i] = result[i];
            for (j=0; j<size2; ++j) first2[j] = result[j+size1];
            delete[] result;
            return;
        }
    }
}
void MergeSort (int *first, int *last){
    int size = last - first;
    if(size <= 1) return;
    MergeSort(first, first+size/2);
    MergeSort(first+size/2, last);
    merge(first, first+size/2, first+size/2, last);
}


int gcd(int a, int b)
{
    int c;

    if (a < b) {
        a+=b; b=a-b; a-=b;
    }

    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }

    return a;
}

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



    int N;

    while(1){

      vi v;
      cin >> N;
      if(N == 0) break;

      int av;
      REP(i, N){
        int temp;
        cin >> temp;
        v.push_back(temp);
      }

      sort(v.begin(), v.end());

      int sum = 0;
      
      sum = accumulate(v.begin(), v.end(), 0)-v[0]-v[N-1];

      av = sum/(v.size()-2);

      cout << av << endl;
    }

    return 0;
  }

C++: #include<iostream>
#include<algorithm>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define PII pair<int,int>
#define PCC pair<char,char>
#define PCI pair<char,int>
#define PIC pair<int,char>
#define MP make_pair
#define DEBUG(x) cout<<#x<<": "<<x<<endl;

int main()
{
	int n;
	for (; cin >> n, n != 0;)
	{
		int Min = INF;
		int Max = -1;
		int sum = 0;
		REP(i, n)
		{
			int temp;
			cin >> temp;
			Min = min(Min, temp);
			Max = max(Max, temp);
			sum += temp;
		}
		sum =sum - Min - Max;
		int ans = sum / (n-2);
		cout <<ans<< endl;
	}
	return 0;
}

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

int a,b=0,temp;
int maxi=0;
int mini=100000;
long sum=0;
int result[1000];

int main(){

  while(cin >> a && a!=0){
    for(int i=0;i<a;i++){
      cin >> temp;
      sum+=temp;
      if(temp>maxi)maxi=temp;
      if(temp<mini)mini=temp;
      //cout <<maxi<<mini<<sum<< endl;
    }
    result[b]=(sum-maxi-mini)/(a-2);
    b++;
    //cout << (sum-maxi-mini)/(a-2) << endl;
    maxi=0;
    mini=100000;
    sum=0;
    //temp=0;
  }

  for(int i=0;i<b;i++){
    cout << result[i] << endl;
  }
}

C++: #include<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(itr,data) for(__typeof((data).begin()) itr=(data).begin();itr!=(data).end();++itr)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long UInt64;
typedef long long Int64;

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

using namespace std;

typedef pair<int ,int > P;

int n;
int solve() {
    int max;
    int min;
    int s;
    cin>>s;
    int sum=s;
    max=min=s;
    rep(i,n-1) {
        cin>>s;
        sum+=s;
        max=std::max(max,s);
        min=std::min(min,s);
    }

    sum-=max;
    sum-=min;

    return sum/(n-2);

}

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

        if(!n) return 0;

        cout<<solve()<<endl;

    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int judge;
int maxscore =0;
int minscore =0;
cin >> judge;
int score[judge];
	for(int i=0; i<judge; i++){
	cin >> score[i];
		if(score[i] > maxscore){
		maxscore = score[i];
		}
		if(score[i] < minscore){
		minscore = score[i];
		}
		if(i==0){
		minscore = score[0];
		}
	}
int lastscore = 0;
for(int j=0;j<judge;j++){
lastscore +=  score[j];
}
lastscore = (lastscore - maxscore - minscore)/(judge - 2);
cout << lastscore <<endl;
return 0;
}