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 <queue>
#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 <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long toLong(string s) {long 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 pair<long, long> PLL;
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(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const int INF = 10000;

struct edge{int to,cost;};
typedef pair<int,int> P;//firstは最短距離,secondは頂点番号


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

C++: using namespace std;
int main(){
	int n,t;
	while(cin>>n,n){
		int mx=0,mn=1000,s=0;
		for(int i=0;i<n;i++){
			cin>>t,s+=t;
			if(t>mx)mx=t;
			if(t<mn)mn=t;
		}
		cout<<(s-mx-mn)/(n-2)<<endl;
	}
	return 0;
}

C++: 
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <iomanip>
#include <functional>
using namespace std;
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

int main(int argc, char* argv[])
{
			int ninzu=0;
	while(cin >> ninzu){
		int ans=0;
		int i=0;
		int temp=0;
		int a=0;

		vector <int>  s;

		
		for(i=0;i<ninzu;i++){
			cin >> a;
			if(temp < a){
				temp = a;
			}
			s.push_back(a);
			if(a == 0)break;
		}

		sort( ALL(s) );

		for(i=1;i<s.size()-1;i++){
			if(s[i] != temp || s[i] != 0)ans+= s[i];
		}

		ans = ans / (i-1);

		cout << ans << endl;
		ans=0;
	}

    return 0;
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        int sum = 0, max = 0, small = 2 << 20;
        int point;
        rep(i,n){
            cin >> point;
            sum+= point;
            if(max < point) max = point;
            if(small > point) small = point;
        }
        cout << (sum - (max + small) ) / (n - 2) << endl;
    }
}

C++: # encodign: utf-8

while true do
    # ????°??????§???????????? (?????????0??\???1000??\???)
    max = -1
    min = 1001
    # ????¨?????????????
    sum = 0
    # n??????
    n = gets.to_i
    break if n == 0 # 0?????¨????????????
    # n?????????????????????
    n.times do
        v = gets.to_i
        min = v if v < min
        max = v if v > max
        sum += v
    end
    sum -= (min + max)
    p sum / (n-2)
end

C++: #include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  int n;
  while(true){
    cin >> n;
    if(n == 0) break;
    int sum = 0,average = 0;
    vector<long long> x(n);
    rep(i,n) cin >> x.at(i);
    sort(x.begin(),x.end());
    for(int i = 1; i < n-1; i++){
      sum +=x.at(i);
    }
    average = sum /(n-2);
    cout << average << endl;
  }
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

#define PREP(i, m, n) for(int i = m; i < n; i++)
#define MREP(i, m, n) for(int i = m - 1; i >= n; i--)

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define prime first
#define weight second
#define MP make_pair
#define PB push_back

using namespace std;

int main(){
	int n = 0;
	while(cin >> n && n != 0){
		map<int, int> ev;
		int max = 0, min = 1000;
		rep(i, n){
			int s = 0;
			cin >> s;

			if(s > max) max = s;
			else if(s < min) min = s;

			if(ev.find(s) != ev.end()) ev[s]++;
			else ev[s] = 1;
		}

		ev[max]--;
		ev[min]--;

		int result = 0, factor = 0;
		for(map<int, int>::iterator it = ev.begin(); it != ev.end(); it++){
			for(int i = 0; i < it->second; i++){
				result += it->first;
				factor++;
			}
		}

		cout << result / factor << endl;
	}
	

	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        int a[10000];
        for(int i = 0;i < n;i++){
            cin>>a[i];
        }
        sort(a,a+n);
        int sum = 0;
        for(int i = 1;i < n-1;i++){
            sum += a[i];
        }
        sum /= n-2;
        cout<<sum<<endl;
    }
    return 0;
}

C++: #include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int a,n;
  int sm,mx,mn;
  while(cin>>n&&n){
    sm=0;
    mx=0;
    mn=1000;
    for(i=0;i<n;i++){
      cin>>a;
      sm+=a;
      if(mx<a)
	mx=a;
      if(mn>a)
	mn=a;
    }
    cout<<(sm-mn-mx)/(n-2)<<endl;
  }
  return 0;
}