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>

using namespace std;

int main(void) {
	int n[20], s[20][100], sum[20], shift;
	int j = 0;
	while (1) {
		sum[j] = 0;
		cin >> n[j];
		if (n[j] == 0)
			break;

		for (int i = 0; i < n[j]; i++) {
			cin >> s[j][i];
		}

		// 昇順ソート
		for (int i = 0; i < n[j]; i++) {
			for (int t = i + 1; t < n[j]; t++) {
				if (s[j][i] > s[j][t]) {
					shift = s[j][i];
					s[j][i] = s[j][t];
					s[j][t] = shift;
				}
			}
		}
		for (int i = 1; i < n[j] - 1; i++) {
			sum[j] += s[j][i];
		}
		sum[j] = sum[j] / (n[j] - 2);
		cout <<  sum[j] << endl;
		j++;

	}
	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int s[100][100];
	int sum[100];
	int change;
	int n=1;
	int i, t,j;
	j = 0;
	while (n)
	{
		sum[j] = 0;
		scanf("%d", &n);
		for (i = 0; i < n; i++)
		{
			scanf("%d", &s[j][i]);
		}
		for (i = 0; i < n; i++)
		{
			for (t = i; t < n; t++)
			{
				if (s[j][i] < s[j][t])
				{
					change = s[j][i];
					s[j][i] = s[j][t];
					s[j][t]=change;
				}
			}
		}
		for (i = 1; i < n - 1; i++)
		{
			sum[j] += s[j][i];
		}
		sum[j] = sum[j] / (n - 2);
		j++;
	}
	for (i = 0; i < j-1; i++)
	{
		printf("%d\n", sum[i]);
	}
	return 0;
}

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  while(1) {
    int n; cin >> n;
    if(n == 0) {
      break;
    }
    vector<int> a(n);
    for(int i=0;i<n;++i) {
      cin >> a[i];
    }
    sort(a.begin(), a.end());
    int su = 0;
    for(int i=1;i<n-1;++i) {
      su += a[i];
    }
    cout << su / (n - 2) << endl;
  }

}

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

int main()
{
	int x[100], i, j = 0, n = 1, sum[100];
	while (1)
	{
		sum[j] = 0;
		cin >> n;
		if (n == 0)
			break;

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

}

C++: #include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

int main(){
  ll N;
  cin>>N;
  ll T[i];
  ll sum=0;
  for(ll i=0; i<N; ++i){
    cin>>T[i];
    sum+=T[i];
  }
  cout<<sum/N<<endl;
  
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int MIN,MAX,n,sum,a,i;
int main(){
while(true){
cin>>n;if(!n){break;}
MIN=10000000;
MAX=0;sum=0;
for(i=0;i<n;i++){cin>>a;MIN=min(MIN,a);MAX=max(MAX,a);sum+=a;}
cout<<sum-MIN-MAX<<endl;
}
}

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

int main() {
	while(true){
		int number;			//?????£??????????????°
		cin >> number;
		if(number == 0){return 0;}

		int score[number];
		int i;
		for(i=0;i<number;i++){	//???????????????
			cin >> score[i];
		}

		int max = 0;			//????????????
		int maxJ;				//?????????????????????????????£??????
		int min = 1001;
		int minJ;
		for(i=0;i<number;i++){	//??????????????¨????°??????????????????????
			if(max < score[i]){
				maxJ = i;
			}
			if(score[i] < min){
				minJ = i;
			}
		}

		int sum = 0;
		for(i=0;i<number;i++){
			if(i != maxJ && i != minJ){
				sum += score[i];
			}
		}
		cout << sum << endl;
	}
}

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

C++: #include<iostream>

using namespace std;

int main() {

	int n=0;
	int s=0;
	int result=0;
	
	cin >> n;

	for (int i = 1; i <= n; i++) {
		cin >> s;
		result = result + s;
	}

	cout << result;

	return 0;

}

C++: #include <iostream>
using namespace std;
int main() {
    int N,input;
    while (1){
        cin >> N;
        if (N==0){
            break;
        }
        int sum=0,max=0,min=1001;
        for (int i;i<N;i++) {
            cin >> input;
            sum += input;
            if (max < input) max = input;
            if (min > input) min = input;
        }
        cout << (sum-max-min)/(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>

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;
	while (true){
		cin >> N;
		if (N == 0){ break; }
		REP(i, N){
			cin >> S[i];
		}
		cout << getAverageScore(N, S)<<endl;
		S.clear();
	}
	return 0;
}

C++: #include<iostream>
#include<numeric>
#include<algorithm>
using namespace std;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
int main(){
    int N,C;
    int ma,mi;
    while(cin>>N&&N>0){
        C=0;
        int a[N];
        for (int i = 0;i < N;++i) {
            cin >> a[i];
        }
        ma = *max_element(a, a + SIZE_OF_ARRAY(a));
        mi = *min_element(a, a + SIZE_OF_ARRAY(a));
        C = accumulate(a, a + SIZE_OF_ARRAY(a), 0);
        C -= mi;
        C -= ma;
        cout << C /(N-2)<< endl;
    }
}