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 <iostream>
# include <vector>
# include <string>
using namespace std;
int main() {
	int n, a;
	while (cin >> n&&n != 0) {
		int sum = 0, min = 10000, max = 0;
		for (int i = 0; i < n; i++) {
			cin >> a;
			if (a < min) {
				min = a;
			}
			if (max < a) {
				max = a;
			}
			sum += a;
		}
		sum = sum - max - min;
		cout << sum / (n - 2) << endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int n;
    while(cin>>n,n){
        int mx=0,mn=1001,s;
        int sum=0;
        rep(i,n){
            cin>>s;
            sum+=s;
            mx=max(mx,s),mn=min(mn,s);
        }
        cout<<(sum-mx-mn)/(n-2)<<endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    int n;
    while(1){
        cin >> n;
        if(n == 0){
            return 0;
        }
        int s_max = 0;
        int s_min = 1000;
        int sum = 0;
        int s;
        for( int i = 0; i < n ; ++i) {
            cin >> s;
            sum += s;
            s_max = max(s, s_max);
            s_min = min(s, s_min);
        }
        int ave = (sum-s_max-s_min)/(n-2);
        cout << ave << endl;
    }
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

#define PREP(i, m, n) for(int i = m; i < n; i++)
#define MREP(i, m, n) for(int i = m - 1; i >= n; i--)

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define prime first
#define weight second
#define MP make_pair
#define PB push_back

using namespace std;

int main(){
	int n = 0;
	while(cin >> n && n != 0){
		map<int, int> ev;
		int max = -1, min = 1001;
		
		rep(i, n){
			int s = 0;
			cin >> s;

			if(s > max) max = s;
			else if(s < min) min = s;

			if(ev.find(s) != ev.end()) ev[s]++;
			else ev[s] = 1;
		}

		ev[max]--;
		ev[min]--;

		double result = 0.0, factor = 0.0;
		
		for(map<int, int>::iterator it = ev.begin(); it != ev.end(); it++){
			rep(i, it->second){
				result += it->first;
				factor++;
			}
		}

		cout << (int)result / (int)factor << endl;
	}
	

	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <climits>
#include <cmath>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>

typedef long long          ll;
typedef unsigned int       uint;
typedef unsigned long long ull;

using namespace std;

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }
    vector<int> s(n);
    for (int i = 0; i < n; i++) {
      cin >> s[i];
    }
    sort(s.begin(), s.end());
    std::cout << accumulate(s.begin() + 1, s.end() - 1, 0) / (s.size() - 2) << std::endl;
  }
}

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

int main(){
	int n, sum, x;
	while(cin >> n, n){
		vector<int> vec;
		for(int i = 0; i < n; i++){
			cin >> x;
			vec.push_back(x);
		}
		sort(vec.begin(), vec.end());

		sum = 0;
		for(vector<int>::iterator it = vec.begin() + 1; it != vec.end() - 1; it++){
			sum += *it;
		}
		cout << sum / (vec.size() - 2) << endl;
	}
}

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

using namespace std;

int main() {
  int n, input;

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

    vector<int> scores;
    for (int i = 0; i < n; i++) {
      cin >> input;
      scores.push_back(input);
    }

    cout << (accumulate(scores.begin(), scores.end(), 0) - *max_element(scores.begin(), scores.end()) - *min_element(scores.begin(), scores.end())) / (n - 2) << endl;
  }

  return 0;
}

C++: aaa

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

int s[100];

int main(){
	int n;
	while(scanf("%d", &n),n){
		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 <iostream>
using namespace std;

int main()
{
	int N, n, sum, largest, smallest;
	sum  = 0; largest = 0; smallest = 1000;
	
	cin >> N;
	
	for(int i = 0; i<N; i++)
	{
		cin >> n;
		sum += n;
		
		if(smallest > n){ smallest = n;}
		if(largest < n){ largest = n;}
	}
	
	cout << (sum-smallest-largest)/(N-2) << endl;
}