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 <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#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)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

  
int main() {
	
	while (1) {
		int n; cin >> n;
		if (n == 0)break;

		int buf; cin >> buf;

		int mi = buf; int ma = buf;

		int sum = buf;
		for (int i = 1; i < n; i++) {
			cin >> buf;
			sum += buf;
			mi = min(mi, buf);
			ma = max(ma, buf);
		}

		cout << (sum-(mi+ma))/(n-2) << endl;
	}
	return 0;
}

C++: //#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <climits>

using namespace std;
using ll=long long;

void solve(){
  while(true){
  int num;
  cin >> num;if(num==0){return;}
  int ma=0,mi=10000,sum=0;
  for(int i=0;i<num;i++){
    int c=0;
    cin >> c;
    ma=max(ma,c);
    mi=min(mi,c);
    sum+=c;
  }
  cout << (sum-ma-mi)/(num-2) << endl;
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int roop=1;
  while(roop--)
    solve();
  return 0;
}

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

using  namespace std;
int n;
void solve(){
  int inputMin=10001, inputMax=-1;
  int score,ans = 0;
  for(int input = 0; input < n ; input ++){
    cin >> score;
    ans += score;
    inputMin = min(inputMin , score);
    inputMax = max(inputMax , score);
  }
  ans = (ans - inputMin -inputMax)/ (n-2);
  cout << ans << endl;
}
int main(){

  while(cin >> n){
    if(n == 0) break;
    solve();
  }


  return 0;
}

C++: #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

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

int n;

void solve()
{
  vector<int> v;
  rep(i, n) {
    int s; cin >> s;
    v.push_back(s);
  }
  sort(v.begin(), v.end());

  int sum = 0;
  repi(i, 1, n - 1) sum += v[i];
  cout << sum / (n - 2) << endl;
}

int main()
{
  while (cin >> n and n) {
    solve();
  }

  return 0;
}

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

int N, S;

int main()
{
   while ( cin >> N && N>0)
   {
      int M, m, addup, i;
      M = -1;
      m = 1001;
      for ( i = 0; i<N; i++)
      {
         cin >> S;
         addup += S;
         if ( S > M) M = S;
         if ( S < m) m = S;
      }
   cout << (addup - M - m)/(N-2)  << endl;
   }
}

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

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n;
	while (cin >> n, n) {
		vector<int> a(n);
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		sort(a.begin(), a.end());
		a.pop_back();
		reverse(a.begin(), a.end());
		a.pop_back();
		cout << accumulate(a.begin(), a.end(), 0) / (n - 2) << endl;
	}
	return 0;
}

C++: //#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <cstring>
#include <climits>
#define INF INT_MAX / 2
using namespace std;

typedef pair<double, double> P;
typedef long long ll;

int main(void) {
  int n;

  while (cin >> n,n!=0) {
    int mi = INF, ma = 0;
    int sum = 0;
    for (int i = 0; i < n; i++) {
      int p;
      cin >> p;
      sum += p;
      mi = min(mi, p);
      ma = max(ma, p);
    }
    sum -= (mi + ma);
    cout << sum / (n-2) << endl;
  }
}

// command ctrl 上下
// command D
// command caps G → '' ""

C++: #include <iostream>

using namespace std;

main(){
  int n;
  while(1){
    cin >> n;
    if(n==0) break;

    int in[100];
    int sum=0;
    for(int i=0;i<n;i++){
      cin >> in[i];
      sum+=in[i];
    }

    int min=100000;
    int max=-1;
    for(int i=0;i<n;i++){
      if(min>in[i]) min=in[i];
      if(max<in[i]) max=in[i];
    }
    sum-=min;
    sum-=max;
    printf("%d\n", (int)(sum/(n-2)));
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
	int n;
	int s;
	int min = 10000;
	int max = 0;
	int sum = 0;
	vector<int> results;
	while(cin>>n){
		if(n==0){
			break;
		}
		for(int j = 0;j<n;j++){
                    cin>>s;
		    sum+=s;
		    if(s>max)
                       max = s;
                    if(s<min)
                       min = s;
		}
		sum = (sum-max-min)/(n-2);
                results.push_back(sum);
                min = 10000;
                max = 0;
                sum = 0;
	}
	int size = results.size();
	for(int i = 0;i<size;i++){
		cout<<results[i]<<endl;
	}
}

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

using namespace std;

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