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 <iostream>
using namespace std;

int main(){

  while(1){
    int n;
    int p[200];
    cin >> n;

    if(n == 0) break;
    int max = -1,min = 2000;
    for(int i = 0;i< n;i++){
      cin >> p[i];
      if(max < p[i])max = p[i];
      if(min > p[i])min = p[i];
    }

    int sum = 0,count=0;
    for(int i = 0;i< n;i++){
      if(p[i] != max && p[i] != min){
	sum += p[i];
	count++;
      }
    }
    cout << sum / count << endl;;

  }
  return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

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

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

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();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	for(int n; cin >> n, n;) {
		vector<int> v(n);
		rep(i,n) cin >> v[i];
		cout << (accumulate(all(v), 0) - *max_element(all(v)) - *min_element(all(v))) / (n - 2) << endl;
	}
	return 0;
}

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

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

}

C++: #include <iostream>
using namespace std;
int main(){
  int n,mx,mn;

  while( cin>>n && n ){
    int sum=0;
    mx = -1;
    mn = 10000;
    for( int i=0,j;i<n;i++ ){
      cin >> j;
      sum +=j;
      if( j>mx ) mx=j;
      if( j<mn ) mn =j;
    }

    sum = (sum - mx -mn)/(n-2);
    cout << sum << endl;
  }
  return 0;
}

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

int main(){
	int n;
	while (std::cin >> n && n){
		std::vector<int> score;
		for (int i = 0; i < n; ++i){
			int s;
			std::cin >> s;
			score.push_back(s);
		}
		std::sort(score.begin(), score.end());
		score.pop_back();
		score.erase(score.begin());
		int ans = 0;
		int cnt = 0;
		for (auto it = score.begin(); it != score.end(); ++it){
			ans += *it;
			cnt++;
		}
		std::cout << ans/cnt << std::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];
		}
		int maxi = 0; mini = 1000000000;
		for (int j = 0; j < a; j++) {
			if (maxi < b[j])
				maxi = b[j];
			if (mini > b[j])
				mini = b[j];
		}
		sum -= maxi + mini;
		c[w] = (sum / (a - 2));
		w++;
	}
	for (int j = 0; j<w; j++)
	{
		cout << c[j] << endl;
	}
}

C++: #include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(x) for(auto it=(x).begin();it!=(x).end();it++) 
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
 
using namespace std;

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

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

using namespace std;

#define rep(i, a) for (int (i) = 0; (i) < (a); (i)++)
#define reps(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define MP(a, b) make_pair((a), (b))
#define pb(a) push_back((a))
#define all(v) (v).begin(), (v).end()


int main()
{
	int n;
	int p;
	int ma, mi;
	cin >> n;
	while (n) {
		int sum = 0;
		ma = 0;
		mi = 1000;
		rep(i, n) {
			cin >> p;
			sum += p;
			ma = max(ma, p);
			mi = min(mi, p);
		}
		cout << (sum-ma-mi) / (n-2) << endl;
		cin >> n;
	}
}

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

int main()
{
    int x;
    while(1){
        cin >> x;
        if(x == 0) break;
        int max = -1, mini = 10000, sum = 0, score = 0, y = 0;
        for(int i = 0; i < x; i++){
           cin >> score;
          sum += score;
          if(score > max) max = score;
            if(score < mini) mini = score;
        }
        sum -= max + mini;
        y = sum / (x - 2);
        cout << y << endl;
    }
    return 0;
}

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);
		j++;
	}
	for (int i = 0; i < j; i++) {
		cout << endl << sum[i];
	}
	cout << endl;
}

C++: #include <stdio.h>

int max = 0;
int min = 1000;

int maximum(int s)
{
	if(max < s){ max = s; }
	
	return max;
}


int minimum(int s)
{
	if(min > s){ min = s; }
	
	return min;
}


int main(void)
{
	int n;
	int i;
	int s;
	
	while(scanf("%d", &n) != EOF){
		int ans = 0;
		int maxi, mini;
		for(i = 0; i < n; i++){
			scanf("%d", &s);
			maxi = maximum(s);
			mini = minimum(s);
			ans += s;		
		}
		ans = (ans - maxi - mini) / (n - 2);
		printf("%d\n", ans);
		
		max = 0;
		min = 1000;
	}
	return 0;
}