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 <vector>
#include <algorithm>

using namespace std;

int main() {
	int n;
	int total;
	int ave;

	while (1) {
		int tmp;
		vector<int> v;
		cin >> n;
		if (n == 0)break;

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

		sort(v.begin(), v.end());

		total = 0;
		for (int i = 0; i<n; i++) {
			total += v[i];
		}

		total = total - (v[0] + v[n - 1]);
		ave = total / (n - 2);

		cout << ave << endl;

		
	}
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

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

C++: while true do

    max = -1
    min = 1001

    sum = 0

    n = gets.to_i


    n.times do
        v = gets.to_i
        min = v if v < min
        max = v if v > max
        sum += v
    end
    sum -= (min + max)
    p sum / (n-2)
end

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
 
  while( true ) {
    long long int n, input;
    cin >> n;
 
    if ( n == 0 ) break;
 
    vector< long long int > s;
 
    for ( long long int i = 0; i < n; i++ ) {
 
      cin >> input;
      s.push_back( input );
 
    }
 
    sort( s.begin(), s.end() );
 
    long long int ans = 0;
 
    for ( long long int i = 1; i < n - 1; i++ ) {
 
      ans += s[i];
 
    }
 
    cout << ans / ( n - 2 ) << endl;
 
  }
 
  return 0;
 
}

C++: #include <bits/stdc++.h>
using namespace std;
int n;
int s[100];

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

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <tuple>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

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 DECIM8  fixed<<setprecision(8) 
#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 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)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    int sum=0,M=0,m=0;
    REP(i,n){
      int tmp;
      cin >> tmp;
      sum+=tmp;
      if(M<tmp) M=tmp;
      if(m>tmp) m=tmp;
    }
    cout << (sum-M-m)/(n-2) << endl;
  }
}

C++: #include<iostream>
#include<algorithm>
int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int n;
	int avg=0;
	int s[100];
	while (true){
		std::cin >> n;
		if (n == 0) break;
		int q = n - 2;
		for (int i = 0; i < n; i++){
			std::cin >> s[i];
		}
		std::sort(s, s + n);
		for (int i = 1; i <= n-2; i++){
			avg += s[i];
			s[i-1] = 0;
			s[i] = 0;
		}
		std::cout << avg /q << "\n";
		int avg = 0;
		
	}
}

C++: #include <iostream>

#include <algorithm>
#include <numeric>

#include <vector>
#include <queue>
#include <stack>
#include <map>

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

using namespace std;

typedef pair<int, int> P;

const int MAX_N = 100;
int n;

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

  while (true) {
    vector<int> scores;

    cin >> n; 
    if (n == 0) break;

    REP(i,n) {
      int s;
      cin >> s;
      scores.push_back(s);
    }

    sort(scores.begin(), scores.end());
    int sum = accumulate(scores.begin() + 1, scores.end() - 1, 0);

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

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n1;
	cin >> n1;
		int a[100000] = { 0 };
		for (int i = 0; i < n1; i++){
			cin >> a[i];
		}
		sort(a, a + n1);
		a[0] = { 0 };
		a[n1 - 1] = { 0 };
		for (int i2 = 1; i2 < n1; i2++){
			a[0] += a[i2];
		}
		cout << a[0] / (n1 - 2) << endl;
		return 0;
}

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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
	int n;
	while(cin >> n, n){
		vector<int> v(n);
		int ma = -1, mi = inf;
		bool a = true, b = true;
		for(int i=0; i < n; i++){
			cin >> v[i];
			if(ma < v[i]) ma = v[i];
			if(v[i] < mi) mi = v[i];
		}
		int sum = 0;
		rep(i, v.size()){
			if(ma == v[i] && a){a = false; continue;}
			if(mi == v[i] && b){b = false; continue;}

			sum += v[i];
		}
		cout << sum/(v.size()-2) << endl;
	}
}

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a,n;
    for(;;){
        vector<int> num;
        cin>>n;
        if(n==0) break;
        for(int i = 0; i < n; i++){
            cin>>a;
            num.push_back(a);
        }
        sort(num.begin(), num.end());
        num.erase(num.begin());
         num.pop_back();
        int sum=0;
        for(int x : num){
            sum+=x;
        }
        sum/=num.size();
        cout<<sum<<endl;
    }
    return 0;
}

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

int main()
{
	while (true)
	{
		int n;
		scanf("%d", &n);
		if (!n) break;
		
		std::vector<int> points(n);
		for (auto& e: points) scanf("%d", &e);
		std::sort(points.begin(), points.end());
		int sum{};
		for (int i{1}; i < n - 1; i++)
			sum += points[i];
		printf("%d\n", sum / (n - 2));
	}

	return 0;
}

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

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