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

package main

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

// 標準入力を取得するScannerのインスタンスを作成
var sc = bufio.NewScanner(os.Stdin)

// 標準入力で各行を読み込み文字列として返す
func readLine() string {
	if sc.Scan() {
		return sc.Text()
	}
	return ""
}

func average() (avg int) {
	// 審判の人数を取得する
	n, _ := strconv.Atoi(readLine())

	// 得点
	score := make([]int, 0, n)

	// 得点を読み込む
	for n > 0 {
		line, _ := strconv.Atoi(readLine())
		score = append(score, line)
		n--
	}

	if len(score) == 0 {
		return 0
	}

	// ソート
	sort.Ints(score)
	// 先頭を削除
	score = append(score[:0], score[1:]...)
	// 末尾を削除
	score = score[:len(score)-1]

	// 合計
	for i := 0; i < len(score); i++ {
		avg += score[i]
	}

	// 平均
	avg = avg / len(score)
	return avg
}

func main() {
	// 改行区切りから単語(スペース)区切りで読み込むように変更する
	sc.Split(bufio.ScanWords)
	for {
		avg := average()
		if avg != 0 {
			fmt.Println(avg)
		} else {
			break
		}
	}
}

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);
    }
}

C++: #include <iostream>
#include <stdlib.h>
using namespace std;
int N, S;
int main()
{
  while (cin >> N && N > 0){
    if (N<3 || N>100)
      exit (1);
    int sum = 0;
    int largest = 0;
    int smallest =1000;
    for (int i=0; i<N; ++i){
      cin >> S;
      if (S<0 || S>1000)
        exit (2);
      sum += S;
      if (largest < S)
        largest=S;
      if (smallest > S)
      smallest=S;
    }
    int average = 0;
    average = (sum - largest - smallest) / (N - 2);
    cout << average << endl;
  }
}

C++: #include <stdio.h>
int max(int a,int b){
    if(a>b)return a;
    return b;
}
int min(int a,int b){
    if(a>b)return b;
    return a;
}
int main(){
    int n,top,bot,tot,temp;
    while(1){
        scanf("%d",&n);
        if(n==0)return 0;
        scanf("%d",&top);
        tot=bot=top;
        for(int i=1;i<n;i++){
            scanf("%d",&temp);
            tot+=temp;
            top=max(top,temp);
            bot=min(bot,temp);
        }
        printf("%d\n",(tot-top-bot)/(n-2));
    }
}

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

int main(){
  int n,a[21],b[21];
  while(1){
    
    cin>>n;
    if(n==0) break;
    for(int i=0;i<n;i++){
      cin>>a[i];
    }
    
    int max=0,min=10001;
    for(int i=0;i<n;i++){
      if(max<a[i]){
	max=a[i];
      }
      if(min>a[i]){
	min=a[i];
      }
    }
    
    int sum=0;
    for(int i=0;i<n;i++){
      sum+=a[i];
    }
    sum-=(max+min);
    
    cout<<sum/(n-2)<<endl;
  }
  return 0;
}

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;
}