Go: // ICPC 得点集計ソフトウェア
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for	{
		n := nextInt(sc)
		if n == 0 { break }

		score_list := []int{}
		for i := 0; i < n; i++ {
			score_list = append(score_list, nextInt(sc))
		}

		// 最低点と最高点を取り除く (3 ≤ n ≤ 100)
		sort.Sort(sort.IntSlice(score_list))
		score_list = score_list[1:len(score_list)-1]

		// 平均点を求める
		sum := 0
		for _, score := range score_list {
			sum += score
		}
		fmt.Println(sum / len(score_list))
	}
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

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

C++: #include<iostream>

using namespace std;

const int calc(int*, int);


int main(){

	int data[100] = {};
	int count = 0;
	while (true){
		cin >> count;
		if (count == 0)break;
		for (int i = 0; i < count; i++){
			cin >> data[i];
		}

		for (int i = 1; i < count; i++){
			for (int j = i; j > 0; j--){
				if (data[j - 1] > data[j]){
					int tmp = data[j];
					data[j] = data[j - 1];
					data[j - 1] = tmp;
				}
			}
		}
		cout << calc(data, count) << endl;
	}

	return 0;
}

const int calc(int* a, int count){
	if (count <= 0)return 0;

	int ave = 0;

	for (int i = 1; i < count - 1; i++)ave += a[i];
	return ave / (count - 2);
}

C++: //
//  main.cpp
//  AOJ1147
//
//  Created by aki33524 on 2014/07/15.
//  Copyright (c) 2014年 aki33524. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[])
{
    int n;
    while(cin>>n, n){
        vector<int> v(n);
        for(int i=0; i<n; i++)
            cin >> v[i];
        sort(v.begin(), v.end());
        int ans = 0;
        for(int i=1; i<n-1; i++)
            ans += v[i];
        cout << ans/(n-2) << endl;
    }
    
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
 
#define ascent(i, a, b) for(int (i) = (a); (i) < (b); (i) ++)

using namespace std;

int main() {
  int n, tmp;
  vector<int> p;
  while(true) {
    cin >> n;
    if(n == 0) break;

    p.clear();
    while(n --) {
      cin >> tmp;
      p.push_back(tmp);
    }

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

    int sum = 0;
    ascent(i, 1, p.size()-1) {
      sum += p[i];
    }

    cout << sum/(p.size()-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;
	}
}

C++: #include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>
#include <stack>
#include <set>
#include <vector>
#include <numeric>

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef pair<int,int> pii;

const int INF = 1 << 29;
const double EPS = 1e-10;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
  return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
  os<<'[';
  rep(i,a.size()) os<<(i?" ":"")<<a[i];
  return os<<']';
}



int main() {
  for (int n; cin >> n, n != 0; ) {
    vi s(n);
    rep(i, n) cin >> s[i];

    cout << (accumulate(all(s), 0) - *max_element(all(s)) - *min_element(all(s))) / (n - 2) << endl;
  }
  
  
  return 0;
}

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

int main(){
	int n, s, sum, max, min, i;
	while((cin >> n), n){
		sum = max = 0;
		min = 1000;
		for(i = 0; i < n; i++){
			cin >> s;
			sum += s;
			max = max(max, s);
			min = min(min, s);
		}
		cout << (int)(sum / n) << endl;
	}
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  while (cin >> n && n) {
    int mx = -1;
    int mn = 1001;
    int sum = 0;
    REP(i, n) {
      int s;
      cin >> s;
      sum += s;
      if (mx < s) mx = s;
      if (s < mn) mn = s;
    }
    int ans = (sum - (mx + mn)) / (n - 2);
    cout << ans << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
using namespace std;
int main(){
int n;
while(cin>>n,n){
vector<int>in;
rep(i,n){
int tmp;
cin>>tmp;
pb(in,tmp);
}
sort(all(in));
int sum=0;
loop(i,1,in.size()-1)sum+=in[i];
cout<<(int)(sum/(n-2))<<endl;
}
}