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())
		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 < n-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

C++: //
//  main.cpp
//  no.1
//
//  Created by MacBook_Virgo on 2015/04/23.
//  Copyright (c) 2015??´ MacBook_Virgo. All rights reserved.
//

#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    int n;
    while(cin >> n,n!=0){
    int max,min;
    max = 0;
    min = 1000;
    int x;
    int sum = 0;
    for(int i = 0;i <n;i = i+1){
        cin >> x;
        sum = sum + x;
        if(x >max){
            max = x;}
        if(x < min){
            min = x;}
    }
    cout << (sum - max - min) / (n-2) << endl;
    }return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

int main() {
	int c[20];   // int[] c = new int[20];
	int w = 0;
	while (true)
	{
		int a;
		cin >>  a;// int a = int.Parse(Console.ReadLine());
		if (a == 0)
			break;
		int sum = 0;
		int b[a];
		for (int j = 0; j < a; j++)
		{
			cin >> b[j];
			sum += b[j];
		}
		sum -= b.Max() + b.Min();
		c[w] = (sum / (a - 2));
		w++;
	}
	for (int j = 0; j<w; j++)
	{
		cout << c[j] << endl;
	}
}

C++: #include<cstdio>
#include<algorithm>
using namespace std;
int n,s[100];

int main()
{
        scanf("%d",&n);
        if (n==0) return 0;
        for (int i=0;i<n;i++){
                scanf("%d",s+i);
        }
        sort(s, s+n);
        int k=0;
        for (int i=1;i<n-1;i++){
                k+=s[i];
        }
        k/=n-2;
        printf("%d\n",k);
        main();
}

C++: #include<iostream> 
using namespace std; 
int main(){ 
  int n; 
  int t[100],mx,mn,sum; 
  while(1){ 
    cin>>n; 
    if(n==0)break; 
    mx=sum=0; 
    mn=1000; 
    for(int i=0;i<n;i++){ 
      cin>>t[i]; 
      if(mn>t[i])mn=t[i]; 
      if(mx<t[i])mx=t[i]; 
      sum+=t[i]; 
    } 
    sum-=mn; 
    sum-=mx; 
    cout<<sum/(n-2)<<endl; 
      
  } 
  return 0; 
}

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

using namespace std;

void solve(int n){
  list <int> s;
  for(int i = 0 ; i < n ; i++ ){
    int a;
    cin >> a;
    s.push_back(a);
  }
  
  int s_max = 0;
  int s_min = 0xFFFF;
  list<int>::iterator s_max_it;
  list<int>::iterator s_min_it;

  for(auto it = s.begin() ; it != s.end() ; it++ ){
    if(*it > s_max){
      s_max = *it;
      s_max_it = it;
    }
    if(*it < s_min){
      s_min = *it;
      s_min_it = it;
    }
  }
  
  s.erase(s_max_it);
  s.erase(s_min_it);

  int sum = 0;
  for(auto it = s.begin() ; it != s.end() ; it++ ){
    sum += *it;
  } 
  cout << sum / (n-2) << endl;
  return;
}

int main(){
  
  while(1){
  
  int n;
  cin >> n;
  
  if(n > 0)
    solve(n);
  else
    break;

  }

  return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n,a[1000],c;
	while(true){
		cin>>n;
		if(n==0){
			break;
		}
		c=0;
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		sort(a,a+n);
		for(int i=1;i<n-1;i++){
			c+=a[i];
		}
		cout<<c/(n-2)<<endl;
	}
	return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
	int n;
	int tem;
	int sum;


	while(1){
		cin>>n;
		if(n==0) break;

		sum=0;
		vector<int> v;
		for(int i1=0; i1<n; i1++){
			cin>>tem;
			v.push_back(tem);
			sum+=tem;
		}
		sort(v.begin(), v.end());
		sum-=(v[0]+v[v.size()-1]);
		cout<<sum/(n-2)<<endl;
		
	}

	return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    int n; //審判の数

    while(true){
        int s[1010]; //各審判のつけた点数
        cin >> n;
        if(n == 0) break;

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

        int max = 0, min = 1000; //点数の最小値、最大値
        for(int i = 0; i < n; i++){
            if(s[i] > max) max = s[i];
            if(s[i] < min) min = s[i];
        }

        int sum = 0; //最高点と最低値を除いた点数たちの和
        int mean; //最高点と最低値を除いた点数の平均値
        for(int i = 0; i < n; i++){
            sum += s[i];
        }
        mean = (sum - max - min) / (n - 2);

        cout << mean << endl;
    }
}

C++: #include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

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


    }

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define lout cout
#else
stringstream devnull;
#define lout devnull
#endif
template <class C>
inline void vcin(C &a);
template <class C>
inline void vcout(const C a, const string separate = "\n");

int main()
{
  while (true)
  {
    int n;
    cin >> n;
    if (n == 0)
    {
      break;
    }
    vector<int> s(n);
    vcin(s);
    sort(s.begin(), s.end());
    s.erase(s.begin());
    s.pop_back();
    cout << accumulate(s.begin(), s.end(), 0) / s.size() << endl;
  }
  return 0;
}

template <class C>
inline void vcin(C &c)
{
  for (auto &a : c)
  {
    cin >> a;
  }
}
template <class C>
inline void vcout(const C c, const string separate)
{
  for (auto it = c.begin(); it != c.end(); it++)
  {
    if (it != c.begin())
      cout << separate;
    cout << *it;
  }
}