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
//------------------------------------------
#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>
#include<climits>
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;
	int b;
	int c = INT_MAX;
	while (true){
		if (c != INT_MAX){ cout << endl; }
		cin >> N;
		if (N == 0){ break; }
		REP(i, N){
			cin >> b;
			S.push_back(b);
		}
		c = getAverageScore(N, S);
		cout << c;
		S.clear();
	}
	return 0;
}

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

using namespace std;

int main(){
  int n,s[1000];

  while(cin >> n){
    int sum;
    if(!(n)) break;
    sum = 0;
    for(int i = 0;i<n;i++) cin >> s[i],sum += s[i];
    sort(s,s+n);
    printf("%d\n",(sum - s[0] - s[n-1]) / (n-2));
  }

  return 0;
}

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

using namespace std;

const int INF = 100000000;

int main(){
	int size;
	while(cin >> size,size!=0){
		//sizeに標準入力して、その値が0でない間ループ
		//while(cin >> size,size)と書く人のほうが多い(意味は同じ)。ソースを読むときの参考に
		//scanfを使う場合はcin >> size の部分をscanfで入力するようにすればよい。
		int maxv = -INF;
		int minv = INF;
		int sum = 0;
		for(int i=0;i<size;i++){
			int num;
			cin >> num;
			sum+=num;
			maxv = max(maxv,num);
			minv = min(minv,num);
		}
		int result = (sum-minv-maxv)/(size-2);
		cout << result << endl;
	}
}

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

using namespace std;

int main(void) {
		for (;;) {
			int n;
			scanf("%d", &n);
			if (n == 0) { break; }

			int s_max = 0;
			int s_min = 100000000;
			int sum = 0;

			for (int i = 0; i < n; i++) {
					int s;
					scanf("%d", &s);

					sum += s;
					s_max = max(s, s_max);
					s_min = min(s, s_min);
			}

			sum -= s_max;
			sum -= s_min;

			printf("%d\n", sum / (n - 2));
		}
		return 0;
}

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

int main()
{
    int a,b[100];
    cin>>a;
    int max=0,min=1000,sum=0,result=0;
    for(int i=0;i<a;i++){
        cin>>b[i];
        sum+=b[i];
        if(b[i]<min){
            min=b[i];
        }
        if(b[i]>max){
            max=b[i];
        }
    }
    result=sum-min-max;
    cout<<result/(a-2);
    return 0;
}

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

int main(void)
{
	int data[101];
	int n;
	int sum;
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		for (int i = 0; i < n; i++){
			scanf("%d", data + i);
		}
		std::sort(data, data + n);
		sum = 0;
		for (int i = 1; i < n - 1; i++){
			sum += data[i];
		}
		printf("%d\n", sum / (n - 2));
	}
	return (0);
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,s[100],ave,flag1,flag2;
  bool a,b;
  while(cin >>n && n!=0){
    a=false;b=false;
    flag1=0;flag2=0;
    ave=0;
    for(int i=0;i<n;i++) cin >>s[i];
    sort(s,s+n);

    if(s[0]==s[1]){
      a=true;
    for(int i=1;i<n;i++){
      if(s[0]==s[i]){
	flag1++;
	s[i]=0;}
      else break;
    }
    }
    else if(s[0]==s[1])
    if(s[n-1]==s[n-2]){
	b=true;
    for(int i=n-2;i>=0;i--){
      if(s[n-1]==s[i]){
	flag2++;
	s[i]=0;}
      else  break;
    }
    }

  for(int i=1;i<n-1;i++) ave+=s[i];
  if(a==true){
    n-=flag1;
    ave+=s[0];}
    else n-=1;
  if(b==true){
    n-=flag2;
    ave+=s[n-1];}
    else n-=1;
    ave/=n;
    cout <<ave<<endl;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
typedef long long i64;
int main(){
  while(true){
    int n;
    vector<int> a;
    cin >> n;
    if(n==0) break;
    rep(i,n){
      int b;
      cin >> b;
      a.push_back(b);
    }
    sort(a.begin(),a.end());
    int total=0;
    repi(i,1,n-1){
      total+=a[i];
    }
    cout << total/(n-2) << endl;;
  }
  return 0;
}

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

int main()
{
    for(int j=0;j<20;j++){
    int n,sum=0;
    cin >> n;
    if(n==0){
        break;
    }
    vector<int> score(n);
    for(int i=0;i<n;i++){
        cin >> score.at(i);
    }
    sort(score.begin(),score.end());
    for(int i=1;i<n-1;i++){
        sum+=score.at(i);
    }
    cout << sum/(n-2) << endl;
    }
    return 0;
}

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

int main()
{
	int N, d[1000];
	while(cin >> N, N)
	{
		for(int i=0; i<N; i++)
			cin >> d[i];

		sort(d,d+N);
		int ret=0;
		for(int i=1; i<N-1; i++)
			ret+=d[i];

		cout << ret/(N-2) << endl;
	}
}

C++: #include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int n;
	while(scanf("%d",&n),n) {
		int s,sum=0,min_s=1<<30,max_s=0;
		for(int i=0;i<n;i++) {
			scanf("%d",&s);
			sum+=s;
			min_s=min(min_s,s);
			max_s=max(max_s,s);
		}
		printf("%d\n",(sum-min_s-max_s)/(n-2));
	}
}