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++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

void reader(int &a) { scanf("%d", &a); }
void reader(double &a) { scanf("%lf", &a); }
void reader(char a[]) { scanf("%s", a); }
void reader(char &a) { scanf(" %c", &a); }
void reader(ll &a) { scanf("%lld", &a); }
void reader(ull &a) { scanf("%llu", &a); }
// void reader(string& a){cin >> a;};
template<class T, class U> void reader(T& t, U& u) { reader(t); reader(u); }
template<class T, class U, class V> void reader(T& t, U& u, V& v) { reader(t); reader(u); reader(v); }

void writer(const int a, char c) { printf("%d", a); putchar(c); }
void writer(const ll a, char c) { printf("%lld", a); putchar(c); }
void writer(const ull a, char c) { printf("%llu", a); putchar(c); }
void writer(const double a, char c) { printf("%.20lf", a); putchar(c); }
void writer(const char a[]) { printf("%s", a); };
void writer(const char a[], char c) { printf("%s", a); putchar(c); };
void writer(const char a, char c) { putchar(a); putchar(c); };
template<class T> void writerLn(T t) { writer(t, '\n'); }
template<class T, class U> void writerLn(T t, U u) { writer(t, ' '); writer(u, '\n'); }
template<class T, class U, class V> void writerLn(T t, U u, V v) { writer(t, ' '); writer(u, ' '); writer(v, '\n'); }
template<class T> void writerArr(T x[], int n) { int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }
template<class T> void writerVec(vector<T> x) { int n = x.size(); int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }

vector<string> split(const string &str, char sep) { vector<string> v; stringstream ss(str); string buffer; while (getline(ss, buffer, sep)) { v.push_back(buffer); }return v; }
// #define int ll
bool test = 1;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define MAX 300000
//.....................
ull mod = (int)1e9 + 7;

string target;
int ts;
struct Group1 {
	int a, b;
	bool operator < (const Group1 &g) const {
		// if (a == g.a) return b > g.b;
		return a < g.a;
	}
}; 
struct Group2 {
	int a, b;
	bool operator < (const Group2 &g) const {
		// if (b == g.b) return a > g.a;
		return b > g.b;
	}
};

signed main(void)
{
	int N;
	while (1) {
		cin >> N;
		if (N == 0) break;
		vector<int> v(N);
		rep(i, N) {
			cin >> v[i];
		}
		sort(ALL(v));
		int sum = 0;
		REP(i, 1, v.size() - 1) {
			sum += v[i];
		}
		cout << sum/(N-2) << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<numeric>
#include<map>
#include<math.h>

using namespace::std;

int main(void)
{
  int n;
  vector<int> s;

  while(cin >> n && n != 0)
    {
      int tempS;
      s.clear();

      for(int i = 0; i < n; i++)
	{
	  cin >> tempS;
	  s.push_back(tempS);
	}

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

  return 0;
}

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

int main(void){
  while(true){
    long n;
    cin >> n;
    if(n == 0){
      break;
    }
    vector<long> S;
    for(int i = 0; i < n;++i){
      long s;
      cin >> s;
      S.push_back(s);
    }
      long mx = *max_element(S.begin(), S.end());
      long mn = *min_element(S.begin(), S.end());
      long sum = accumulate(S.begin(), S.end(), 0);
      cout << (sum - mx - mn) / (n - 2)  << endl;
  }
 return 0;
}

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

int main(void){
  while(true){
    int n;
    cin >> n;
    if(n == 0){ break; }

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


  return 0;
}

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

int main()
{
  int n,s,i,sum;
  multiset<int> ms;
  multiset<int>::iterator it,ite;
  while(cin>>n,n){
    ms.clear();
    for(i=0;i<n;i++){
      cin>>s;
      ms.insert(s);
    }
    sum=0;
    ite=ms.end();
    ite--;
    it=ms.begin();
    for(it++;it!=ite;it++)sum+=*it;
    cout<<sum/(n-2)<<endl;
  }
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REPR(i, n) for (int i = (n)-1; i >= 0; i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase(unique(ALL(v)), v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 2e18;
const double PI = acos(-1);

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	while (N != 0)
	{

		int mav = 0;
		int miv = 1000;
		int sum = 0;
		REP(i, N)
		{
			int a;
			cin >> a;
			sum += a;
			mav = max(mav, a);
			miv = min(miv, a);
		}
		cout << (sum - mav - miv) / (N - 2) << endl;
		cin >> N;
	}
	return 0;
}

C++: // includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  while(1) {
    int n;
    cin >> n;
    if(!n) break;
    vector<int> v(n);
    for(auto &e: v) cin >> e;
    sort(begin(v), end(v));
    ll sum = 0;
    for(int i = 1; i < n - 1; i++) sum += v[i];
    cout << sum / (n - 2) << "\n";
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	int x[1000] = { 0 };
	int y[20] = { 0 };
	int max;
	int min;
	n = 1;
		int j = 0;
		while (n != 0){
			
			cin >> n;
			max = 0;
			min = 1000;
				y[j] = 0;
			for (int i = 0; i < n; i++){
				cin >> x[i];
				if (max < x[i]) max = x[i];
				if (min > x[i]) min = x[i];
				y[j] += x[i];
			}
			y[j] -= max + min;
			y[j] = y[j] / (n - 2);
			j++;
		}
	for (int k = 0; k < j; k++){
		cout << y[j]<< endl ;
	}
	return 0;
}