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 <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;


int main() {
  int n;

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

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

    int  sum = 0;
    int _max = scr[0];
    int _min = scr[0];

    for (int s : scr) {
      sum  += s;
      _min = min(_min, s);
      _max = max(_max, s);
    }

    sum -= _max;
    sum -= _min;

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

C++: #include<stdio.h>
int main(){
  int a,b,c,d,i,j=0,dt[1000],ls[1000],max,min,l,sum;
  while(1){
    scanf("%d",&a);
    if(a==0)break;
    sum=0;
    max=0;
    min=10000;
    for(i=0;i<a;i++){
      scanf("%d",&b);
      dt[i]=b;
    }
    for(i=0;i<a;i++){
      if(dt[i] > max) max=dt[i];
      if(dt[i] < min) min=dt[i]; 
    } 
    for(i=0;i<a;i++){
      if(dt[i]==max) 
	max=0;
      else if(dt[i]==min)
	min=0;
      else sum+=dt[i];
    }
    ls[j]=sum/(a-2);
    j++;
  }
  for(l=0;l<j;l++)
    printf("%d\n",ls[l]);
  return 0;
}

C++: #include <iostream>

using namespace std;


int main(void) {
    int n;
    int score, sum_score;
    int max_score, min_score;
    int i;

    cin >> n;
    while (n) {
        sum_score = 0;
        max_score = 0;
        min_score = 1000;
        for (i=0; i<n; i++) {
            cin >> score;
            sum_score += score;
            if (score < min_score) {
                min_score = score;
            }
            if (score > max_score) {
                max_score = score;
            }
        }

        sum_score -= min_score + max_score;
        cout << sum_score / (n-2) << endl;

        cin >> n;
    }

    return 0;
}

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

int main()
{
  int n;
  while(cin >> n){
    if(n == 0) break;
    int sum = 0;
    int s[100];
    for(int i = 0; i < n; i++)
      cin >> s[i];
    sort(s, s + n);
    for(int i = 1; i < n - 1; i++)
      sum += s[i];
    cout << sum / (n - 2) << endl;
  }
}

C++: #include <stdio.h>
#include <algorithm>

int main(void)	{
	while (true)	{
		int umpire, temp, summ, mini, maxi;
		mini = 1000;
		maxi = 0;
		summ = 0;
	
		scanf("%d", &umpire);
		if (umpire == 0)	{
			break;
		}
		for (int i = 0; i <= umpire - 1; i++)	{
			scanf("%d", &temp);
			mini = std::min(mini, temp);
			maxi = std::max(maxi, temp);
			summ = summ + temp;
		}
		printf("%d\n", (summ - mini - maxi) / (umpire - 2));
	}
	return 0;	
}

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

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int inf = 1000000000;
const int mod = 1000000007;
const double EPS = 1e-9;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

int n;
int s[100];

int main() {
	// cin.tie(0); // tie
	// ios::sync_with_stdio(false); // sync
	while (cin >> n, n) {
		int mini = 10000, maxi = -1;
		int sum = 0;
		rep(i, n) {
			int s; cin >> s;
			if (mini > s) mini = s;
			if (maxi < s) maxi = s;
			sum += s;
		}
		int av = (sum - mini - maxi) / (n - 2);
		cout << av << endl;
	}
	return 0;
}

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

int main()
{
	int n;
	for (; cin >> n, n != 0;)
	{
		int sum = 0;
		int max = -1;
		int min = 1001;
		int s[100];
		for (int i = 0; i < n; i++)
		{
			cin >> s[i];
			max = (max < s[i]) ? s[i] : max;
			min = (min > s[i]) ? s[i] : min;
			sum += s[i];
		}
		cout << (sum - (max + min)) / (n - 2) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main(){
  int n;
  while(1){
    cin >> n;
    if(n==0)break;
    vector<int> p(n);
    int sum=0;
    rep(i,n){
      cin >> p[i];
      sum += p[i];
    }
    int min,max;
    min=*min_element(p.begin(),p.end());
    max=*max_element(p.begin(),p.end());
    sum -= (max+min);
    int avg = sum / (n-2);
    cout << avg << endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int s[101];
int main(){
  int n;
  while(cin>>n,n){
    int sum=0;
    for(int i=0;i<n;++i) cin>>s[i];
    sort(s,s+n);
    for(int i=1;i<n-1;++i) sum+=s[i];
    cout<<sum/(n-2)<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main() {
    int N,input;
    while (1){
        scanf("%d", &N);
        if (N==0){
            break;
        }
        int sum=0,max=0,min=1001;
        for (int i;i<N;i++) {
            cin >> input;
            sum = sum+input;
            if (max < input) max = input;
            if (min > input) min = input;
        }
        printf("%d\n", (sum-max-min)/(N-2));
    }
}

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=10000;
    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>
#include <string>
#include <vector>

using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0 ;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int sum=0;
    for (int i=0;i<n-1;i++){
        sum+=a[i];
    }
    cout << (float) sum /(float) (n-2)<<endl;
}