Go: /*
	Problem A: ICPC 得点集計ソフトウェア
	http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// 標準入力を取得するScannerのインスタンスを作成
var sc = bufio.NewScanner(os.Stdin)

// 標準入力で各行を読み込み文字列として返す
func readLine() string {
	if sc.Scan() {
		return sc.Text()
	}
	return ""
}

func average() (avg int) {
	// 審判の人数を取得する
	n, _ := strconv.Atoi(readLine())

	// 得点
	score := make([]int, 0, n)

	// 得点を読み込む
	for n > 0 {
		line, _ := strconv.Atoi(readLine())
		score = append(score, line)
		n--
	}

	if len(score) == 0 {
		return 0
	}

	// ソート
	sort.Ints(score)
	// 先頭を削除
	score = append(score[:0], score[1:]...)
	// 末尾を削除
	score = score[:len(score)-1]

	// 合計
	for i := 0; i < len(score); i++ {
		avg += score[i]
	}

	// 平均
	avg = avg / len(score)
	return avg
}

func main() {
	// 改行区切りから単語(スペース)区切りで読み込むように変更する
	sc.Split(bufio.ScanWords)
	for {
		avg := average()
		if avg != 0 {
			fmt.Println(avg)
		} else {
			break
		}
	}
}

C++: #include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int main(){
	while(1){
		int N, s, i, sum = 0, maxs = 0, mins = 1001;
		scanf("%d", &N);
		if(N == 0){
			return 0;
		}
		for(i = 0; i < N; i++){
			scanf("%d", &s);
			sum += s;
			maxs = max(maxs, s);
			mins = min(mins, s);
		}
		printf("%d\n", (sum - maxs - mins) / (N - 2));
	}
}

C++: #include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
  int n;
  int po[4000]; 
  while(1)
    {
      cin >> n;
      if(n == 0)break;
      int k;
      for(k=0;k<n;k++)
	{
	  cin >> po[k];
	}
      sort(po,po+k,greater<int>());
      int ans=0;
      for(int i=1;i<k-1;i++)
	{      
	  ans+=po[i];
	}
      cout << floor(ans/(k-2)) << endl;
    }
}

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

using namespace std;
#define all(a)a.begin(),a.end()
const int INF = 1<<30;
const int mod= int(1e9)+7;

int main(){
    while(1){
        int n;cin >>n;
        if(n==0)break;
        int k=n-2;
        int sum=0;
        int mx=-1;int mint=INF;
        for (int i = 0; i < n; ++i) {
            int s;cin >>s;
            mx=max(mx,s);
            mint=min(mint,s);
            sum+=s;
        }
        sum-=(mint+mx);
        cout <<sum/k<<endl;
    }
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main()
{
        while(true)
        {
                int n,A[100]={0};
                cin>>n;
                if(n==0) break;
                rep(i,n) cin>>A[i];
                sort(A,A+n);

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

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

int a[101];

int main(){
	int n;
	while( cin >> n, n ){
		for(int i=0 ; i < n ; i++ )
			cin >> a[i];
		int mx, mn;
		mx = mn = a[0];
		for(int i=1 ; i < n ; i++ ){
			mx = max( mx , a[i] );
			mn = min( mn , a[i] );
		}
		int s = 0;
		for(int i=0 ; i < n ; i++ ){
			if( a[i] == mn ){
				a[i] = 0;
				break;
			}
		}
		for(int i=0 ; i < n ; i++ ){
			if( a[i] == mx ){
				a[i] = 0;
				break;
			}
		}
		for(int i=0 ; i < n ; i++ ){
			s += a[i];
		}
		cout << s/(n-2) << endl;
	}
}

C++: #include<iostream>
using namespace std;
 
int main(){
    int n,i;
    while(cin >> n,n){
        //int point[100]={0,};
		int p;
        int min = 1000;
        int max = 0;
		int total = 0;
        while(n--){
            //cin >> point[i];
			cin >> p;
            //if(point[i] > max) max = point[i];
			if(p > max) max = p;
            //if(point[i] < min) min = point[i];
			//total += point[i];
			if(p < min) min = p;
        }
        cout << (total-max-min)/(n-2) << "\n";
    }

}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int a,b[100];
  while(1)
  {
    scanf("%d",&a );
    if(a == 0)
    {
      break;
    }

    for(int i=0; i<a; i++)
    {
      scanf("%d",&b[i] );
    }

    sort(b,b+a);

    int c = 0;
    for(int i=1; i < a-1; i++)
    {
      c+=b[i];
    }
    printf("%d\n",c / (a-2) );
  }
}

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


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

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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
template<class T> using vv=vector<vector<T> >;

int main() {
  vector<int> results;

  while (true) {
    int count;
    cin >> count;
    if (count == 0) { break; }
    vi point(count);
    for (int i = 0 ; i < count ; i++) {
      cin >> point[i];
    }
    //sort(point.begin(), point.end());
    int max_point = -1;
    int min_point = 1001;
    int ave = 0;
    for (int i = 0 ; i <= point.size()-1 ; i++) {
      ave += point[i];
      if (max_point < point[i]) {
        max_point = point[i];
      }
      if (min_point > point[i]) {
        min_point = point[i];
      }
    }
    ave -= (max_point + min_point);
    ave /= (count-2);
    results.push_back(ave);
  }

  for (int i = 0 ; i < results.size() ; i++) {
    printf("%d\n", results[i]);
  }

  return 0;
}

C++: #include <bits/stdc++.h>
#include <iterator>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(v) begin(v), end(v)
#define rreps(i, a, n) for (ll i = (a); i <= (ll)(n); ++i)
#define rrep(i, n) rreps(i, 0, n)
#define reps(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) reps(i, 0, n)
#define each(i, n) for (auto&& i : n)
#define fill(x, y) memset(x,y,sizeof(x))
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <typename T> inline void print(const T& x) {cout << x << '\n';}

signed main()
{ 
  int n;
  vi ans;
  while(cin>>n, n)
  {
    vi s(n);
    each(v,s) cin>>v;
    sort(ALL(s));
    s.pop_back();
    s.erase(s.begin());
    int sum=0;
    rep(i,s.size()) sum+=s[i];
    ans.push_back(sum/s.size());
  }
  each(v,ans) print(v);

  return 0;
}

C++: #include "algorithm"
#include "iostream"
#include "cmath"
#include "string"
#include "map"
using namespace std;


int main(){
  while(true){
  int n,min=1001,max=-1,sum=0,ten;
  cin >> n;
  if(!n)break;
  for(int i =0;i<n;i++){
    cin >> ten;
    sum+=ten;
    if(min>ten)min=ten;
    if(max<ten)max=ten;
  }
  cout << (sum-min-max)/(n-2) <<endl;
}
  return 0;
}