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++: #include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

const int MAX_N = 110;

int judge_num;
int score[MAX_N];

//---------------------//                                                                                            
int main()
{
        while (cin >> judge_num) {

                if (judge_num == 0) break;

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

                sort(score, score + judge_num);

                int ave;
                double sum_temp = 0;

                for (int i  = 1; i < judge_num - 1; ++i) {
                        sum_temp += score[i];
                }

                ave = (int)( floor( sum_temp / (judge_num - 2) ) );

                cout << ave << endl;
        }

        return 0;
}

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

int main() {
	int n,point,sum,ma,mi;
	
	while(cin>>n){
		if(n==0)break;
		sum=0;
		ma=0;
		mi=1000;
		for(int i=0;i<n;i++){
			cin>>point;
			sum+=point;
			if(ma<point)ma=point;
			if(mi>point)mi=point;
		}
		cout<<(sum-ma-mi)/(n-2)<<endl;;
			}
	
	
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265


void f(int n){

  int a[1000000];

  rep(i,n){
    cin>>a[i];
  }
  sort(a,a+n);

  int ans=0;
  FOR(i,1,n-1){
    ans+=a[i];
  }

  cout<<ans/(n-2)<<endl;
}


int main(){
  while(1){
    int n;
    cin>>n;
    if(n==0) break;
    f(n);
  }


  return 0;
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <tuple>
#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>

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 DECIM8  fixed<<setprecision(8) 
#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))

using namespace std;
int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    int sum=0,M=0,m=0;
    REP(i,n){
      int tmp;
      cin >> tmp;
      sum+=tmp;
      if(M<tmp) M=tmp;
      if(m>tmp) m=tmp;
    }
    cout << (sum-M-m)/(n-2) << endl;
  }
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int n;
int data[100];


int solve() {
  int avg;
  sort(data, data+n);
  avg = 0;
  for(int i = 1; i < n-1; ++i) {
    avg += data[i];
  }
  return avg / (n-2);
}

main() {
  while(( cin >> n ) && n) {
    for(int i = 0; i < n; ++i) {
      cin >> data[i];
    }
    cout << solve() << endl;
  }
}

C++: #include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        int sum = 0, MAX = 0, MIN = 1100;
        rep(i, 0, n){
            int s;
            cin >> s;
            sum += s;
            MAX = max(MAX, s);
            MIN = min(MIN, s);
        }
        cout << (sum - MAX - MIN) / (n - 2) << endl;
    }
}

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

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

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

		if (n == 0) break;

		vector<int> s;
		inputVector(s, n);

		sort(all(s));

		int sum = 0;
		for (int i = 1; i < s.size() - 1; i++) {
			sum += s[i];
		}
		cout << sum / (int)(s.size() - 2) << endl;
	}

    return 0;
}