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>
#include <valarray>
using namespace std;

int main(void){
	int n;
	while(cin>>n,n){
	valarray<int> a(n);
		for(int i=0;i<n;i++)cin>>a[i];
		cout<<(a.sum()-a.max()-a.min())/(a.size()-2)<<endl;
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
 
  while( true ) {
    long long int n;
    long long int a = 0;
    long long int b = 0;
    int input[100];
    cin >> n;
 
    if ( n == 0 ) break;
  
    for ( long long int i = 0; i < n; i++ ) {
 
      cin >> input[i];

      if (input[i] < a)
        a = input[i]

      if (input[i] > b)
        b = input[i] 
    }
 
    long long int ans = 0;
 
    for ( long long int i = 0; i < n; i++ ) {
 
      ans += s[i];
 
    }
 
    cout << (ans - a - b) / ( n - 2 ) << endl;
 
  }
 
  return 0;
 
}

C++: #include <cstdio>
int main()
{
    int n, s[20], i;
    int max, min, ava, sum;
    while (1)
    {
        max = 0;
        min = 1000;
        sum = 0;
        scanf("%d", &n);
        if (n == 0)
        {
            break;
        }
        for (i = 0; i < n; i++)
        {
            scanf("%d", &s[i]);
            if (max < s[i])
            {
                max = s[i];
            }
            if (min > s[i])
            {
                min = s[i];
            }
            sum += s[i];
        }
        sum -= max;
        sum -= min;
        ava = sum / (n - 2);
        printf("%d\n", ava);
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  while(cin >> n&&n){
    vary(ll,v,n,0);
    rep(i,n){
      cin >> v[i];
    }
    sort(all(v));
    v[0] = 0;
    v[v.size()-1] = 0;
    ll ans = 0;
    rep(i,n){
      ans += v[i];
    }
    cout << ans /(n-2) << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
const int INF = 1e9;
const int MODk = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    int n;
    while(cin >> n){
        if(n == 0){
            return 0;
        }
        vector<int> s;;
        for(int a = 0;a < n;a++){
            int b;cin >> b;
            s.push_back(b);
        }
        sort(s.begin(),s.end());
        cout<<(accumulate(s.begin(),s.end(),0LL)-*max_element(s.begin(),s.end())-*min_element(s.begin(),s.end()))/(max(n-2,0))<<endl;;
    }
}

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

using namespace std;

int main()
{
	int n;
	while(cin >> n,n!=0)
	{
		vector<int> s(n);
		for(int i=0;i<n;i++)
			cin >> s[i];
		sort(s.begin(),s.end());
		long long ans=0;
		for(int i=1;i<n-1;i++)
			ans+=s[i];
		ans/=(n-2);
		cout << ans << endl;
	}






}

C++: #include <iostream>
using namespace std;
int N, S;

int main(){
  while( cin >> N && N > 0){ //N??????????????????????????????????????§while????????????
    int sum = 0; 
    int min = 1001; //min????°?????????¨?????????
    int max = -1;
    int average = -1;

    for (int i = 0; i < N; i++){
      cin >> S;
      sum += S;
      if( S > max ) max = S;
      if(S < min) min = S; 
    }

    average = (sum - min - max) / (N - 2); //???N-2?????§???????????¨?????¨??????????????????????????¨????????????????????????

    cout << average << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
using namespace std;

int main(){
	int N,S;
	while(cin>>N,N){
		int sum=0,min_=INT_MAX,max_=INT_MIN;
		for(int i=0;i<N;i++){
			cin>>S;
			min_ = min(min_,S);
			max_ = max(max_,S);
			sum += S;
		}
		printf("%d\n",(sum-min_-max_)/(N-2));
	}
	return 0;
}