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>
using namespace std;

int main(){
  int n, a[100], s;
  while(cin >> n,n){
    s=0;
    for(int i = 0;i < n;i ++){
      cin >> a[i];
    }
    sort(a,a+n);
    for(int i = 1;i < n-1;i ++){
      s += a[i];
    }
    cout << s/(n-2)<< endl;
  }
  return 0;
}

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

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

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

        int max=0,min=1000;;

        for(int i=0;i<n;i++){
            if(s[i]>max)max=s[i];
            else if(s[i]<min)min=s[i];
        }
        
        int sum=0;
        for(int i=0;i<n;i++){
            sum +=s [i];
        }


        sum -=max;
        sum -=min;

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

    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

int main(){
  ll N;
  cin>>N;
  ll T[N];
  ll sum=0;
  for(ll i=0; i<N; ++i){
    cin>>T[i];
    sum+=T[i];
  }
  cout<<sum/N<<endl;
  
}

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

int main(void) {
	for (;;) {
		int n;
		cin >> n;
		if (n == 0)
			break;

		int s[100];
		int max = 0, min = 1000;
		for (int i = 0; i < n; i++) {
			cin >> s[i];
			if (max < s[i]) {
				max = s[i];
			}
			if (min > s[i]) {
				min = s[i];
			}
		}

		bool flag_max = true;
		bool flag_min = true;
		int total = 0;
		for (int i = 0; i < n; i++) {
			if ((s[i] == max) && flag_max) {
				flag_max = false;
				continue;
			} else if ((s[i] == min) && flag_min) {
				flag_min = false;
				continue;
			} else {
				total += s[i];
			}
		}
		int ave = total / (n - 2);
		printf("%d\n", ave);
	}
	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
 
using namespace std;
struct edge{int from, to; ll cost;};

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

    int n, p;
    vector<int> v;
    while(true){
        cin >> n;
        if(n == 0) break;
        
        rep(n){
            cin >> p;
            v.push_back(p);
        }
        sort(all(v));
        cout << accumulate(v.begin()+1, v.end()-1, 0) / (n-2) << endl;
        v.clear();
    }
}

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

using namespace std;

#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000000
#define INFL 10000000000000000LL
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main() {
  while(true){
    int n;
    cin >> n;
    if(n == 0) return 0;
    int a[n];
    REP(i, n) cin >> a[i];
    sort(a, a+n);
    int sum = 0;
    FOR(i, 1, n-1){
      sum += a[i];
    }
    cout << sum/(n-2) << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    int n;
    scanf("%d",&n);
    while(n!=0){
        vector<int> s;
        int sum=0;
        REPR(i,n-1){
            int sn;
            scanf("%d",&sn);
            s.push_back(sn);
        }
        sort(s.begin(),s.end());
        FOR(i,1,s.size()-1){
            sum=sum+s[i];
        }
        int ave=sum/(n-2);
        printf("%d\n",ave);
        scanf("%d",&n);
    }
    return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int n;
int a[111];
int main(void){
  while(cin >> n && n){
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a,a+n);
    int sum = 0;
    for(int i = 1; i < n-1; i++) sum += a[i];
    cout << sum/(n-2) << endl;
  }
}

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

using namespace std;

int main() {
	int N;
	while(cin >> N && N) {
		vector<int> tmp(N);
		int score_max = 0;
		int score_min = 1001;
		int res = 0;
		for(int i = 0; i < N; i++) {
			cin >> tmp[i];
			score_max = max(score_max, tmp[i]);
			score_min = min(score_min, tmp[i]);
			res += tmp[i];
		}
		cout << (res - (score_max+score_min))/(N-2) << endl;
	}

	return 0;
}

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

C++: # encoding: utf-8

while true do
    # ????°??????§???????????? (?????????0??\???1000??\???)
    max = -1
    min = 1001
    # ????¨?????????????
    sum = 0
    # n??????
    n = gets.to_i
    break if n == 0 # 0?????¨????????????
    # n?????????????????????
    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 <bits/stdc++.h>
using namespace std;

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