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 <bits/stdc++.h>
using namespace std;
int n;
long int ans;
int main() {
  for(;;) {
    scanf("%d", &n);
    if(n == 0) break;
    vector<int> v(n);
    for(int i = 0; i < n; ++i) scanf("%d", &v[i]);
    sort(begin(v), end(v));
    v[n - 1] = 0, v[0] = 0;
    for(int i = 0; i < n; ++i) ans+=v[i];
    ans /= n - 2;
    printf("%ld\n", ans);
    n = 0, ans = 0;
    v.clear();
  }
  return 0;
}

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

template<class T> inline void chmax(T& a, T b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, T b) { if(b < a) a = b; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	for(int n; cin >> n, n;) {
		int sum = 0, mx = 0, mn = INT_MAX;
		for(int i = 0; i < n; ++i) {
			int score;
			cin >> score;
			sum += score;
			chmax(mx, score);
			chmin(mn, score);
		}

		cout << (sum - mx - mn) / (n - 2) << endl;
	}

	return EXIT_SUCCESS;
}

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

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

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

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


int main()
{
        int n;
        while (cin >> n, n) {
                vector<int> vs = vector<int>(n);
                rep(i, n) cin >> vs[i];
                sort(vs.begin(), vs.end());
                int ans = 0;
                REP(i, 1, n-1)
                        ans += vs[i];
                ans /= n-2;
                cout << ans << endl;
        }
        return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
//#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    for (int n; cin >> n && n;) {
        VI s(n); cin >> s;
        cout << (accumulate(all(s), 0) - *max_element(all(s)) - *min_element(all(s))) / (n - 2) << "\n";
    }
}

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

using namespace std;

int main(){

  

  int n;

  while(cin>>n){

    if(n==0){
      cout<<endl;
      break;
    }

  int a[n];

  int max,min;

  max=0;
  min=1000;

  for(int i=0;i<n;i++){

    cin>>a[i];

    if(a[i]>max){
      max=a[i];
    }

    if(a[i]<min){
      min=a[i];
    }

  }

  int sum;

  sum=0;

  for(int p=0;p<n;p++){

    sum=sum+a[p];

  }

  sum=sum-max-min;



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

  

  }




  return 0;
}

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

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

	return 0;
}

C++: #include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    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;
        for (int i = 1; i < n - 1; i++)
            sum += v[i];
        cout << sum / (n - 2) << endl;
    }
}

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n;
	while (cin >> n, n != 0) {
		vi s(n);
		int sum = 0;
		rep(i, 0, n) {
			cin >> s[i];
			sum += s[i];
		}
		sum -= *max_element(all(s)) + *min_element(all(s));
		cout << sum / (n - 2) << endl;
	}
}