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 _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;


// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T>
constexpr int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F>
constexpr int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T>
void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C>
void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U>
constexpr void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U>
constexpr void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C>
constexpr void reverse(C& c) { reverse(ALL(c)); }
template<typename C>
constexpr void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred>
constexpr void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9+7)
#pragma endregion


int main()
{
    int n;
    while(cin>>n) {
        if(n==0) break;
        vi v(n);
        rep(i,n) {
            cin >> v[i];
        }
        sort(v);
        remove(v,n-1);
        remove(v,0);
        P(accumulate(ALL(v),0)/v.size());
    }
    return 0;
}

C++: #include <bits/stdc++.h>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;


int a[1010];

int main(void){
	int n;
	while(1){
		cin >> n;
		if(n==0) break;
		rep(i,n) cin >> a[i];
		cout << (accumulate(a,a+n,0)-*max_element(a,a+n)-*min_element(a,a+n))/(n-2) << endl;
	}
}

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

int main() {
    int n;

    while (true) {
        cin >> n;
        if (!n) break;
        vector<int> a(n);
        int sum = 0;
        for (int i = 0; i < n; ++i) cin >> a[i];
        sort(a.begin(), a.end());
        for (int i = 1; i < n-1; ++i) {
            sum += a[i];
        }
        cout << sum/(n-2) << endl;
    }
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n;
	while(cin>>n and n>0){
		int s[n]; rep(i,n) cin>>s[i];
		sort(s,s+n);
		int sum=0;
		for(int i=1;i<n-1;i++){
			sum+=s[i];
		}
		int ans=sum/(n-2);
		cout<<ans<<endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main()
{
  int n;

  while(cin >> n, n){
    int mini = 114514, maxi = -114514;
    int sum = 0;

    for(int i = 0; i < n; i++){
      int s;
      cin >> s;
      sum += s;
      mini = min(mini, s);
      maxi = max(maxi, s);
    }
  
    cout << (sum - mini - maxi) / (n - 2) << endl;
  }
  
  return 0;
}

C++: #include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <utility>
#include <string>

using namespace std;

typedef long long int ll; 
typedef pair<int,int> Pii;

int main(){
    int n,tmp,maxN,minN;
    vector<int> ans;
    int tmpd;
    string num1,num2;
    while(1){
        cin>>n;
        if(n==0)break;
        tmpd=0;maxN=0;minN=1001;
        for(int i=0;i<n;i++){
            cin>>tmp;
            maxN = max(maxN,tmp);
            minN = min(minN,tmp);
            tmpd += tmp;
        }
        ans.push_back((tmpd-minN-maxN)/(n-2));

    }
    for(int i = 0;i<ans.size();i++){
        cout<<ans[i]<<endl;
    }

    return 0;
}

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

using namespace std;

int main(){

   while(1){
      int n;
      cin>> n;
      if(n==0){
         break;
      }
      int s[n];
      for(int i=0; i<n; i++) cin>> s[i];

      int sum=accumulate(s, s+n, 0);
      int mi=*min_element(s, s+n);
      int ma=*max_element(s, s+n);

      cout<< (sum-mi-ma)/(n-2)<< endl;

   }

   return 0;
}

C++: #include <stdio.h>
int main()
{
  int n;
  while(scanf("%d", &n),n){
    int max=0,min=1000,s;
    long sum=0;
    for(int i=0; i<n; i++){
      scanf("%d",&s);
      sum+=s;
      max=max<s ? s : max;
      min=s<min ? s : min;
    }
    printf("%ld", (sum-min-max)/(n-2));
  }
}

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

int main()
{
	int in,a,maxer=0,miner=1000;
	int sum=0;
	int i=0;
	double ave=0.0;
	while( scanf("%d",&in) !=0 ){
		for(i=0; i<in; i++){
			cin >> a;
			maxer=max(a,maxer);
			miner=min(a,miner);
			sum += a;
		}
		sum = sum - maxer - miner;
		ave = sum/(in-2);
		cout << floor(ave) << endl;
		sum = maxer = ave = 0;
		miner=1000;
	}
}

C++: #include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
using namespace std;

#define ll long long
#define MP make_pair

int main(void) {
    int n;

    while(1){
        cin>>n;
        int s[100]={};
        double sum=0.0;
        if(n==0)break;

        for (int i = 0; i < n; i++) {
            cin>>s[i];
        }
        
        sort(s,s+n);
        for (int si = 1; si < n-1; si++) {
            sum+=double(s[si]);
        }
        
        double ave = sum/(double)(n-2);
        cout<<int(ave)<<"\n";

    }
    
    return 0;
}

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

int main(){

  
  int n;
  int sum;
  int s;
  int max,min;

  while(cin >> n){
    if(n==0){ break; }
    sum = 0;
    max=0,min=1000;

    for(int i=0; i<n; i++){
      cin >> s;
      if(s>max){ max=s; }
      if(s<min){ min=s; }

      sum += s;
    }

    sum -= max+min;

    cout << sum/(n-2) << endl;

  }


  return 0;
}