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 <cmath>
#include <cstdio>
using namespace std;
int n;
int a[100];
int M, m, s;
int main()
{
	cin >> n;
	while(n!=0)
	{	
		cin >> a[0];
		M=a[0];
		m=a[0];
		s=a[0];
		for(int i=1; i<n; i++)
		{
			cin >> a[i];
			M=max(M, a[i]);
			m=min(m, a[i]);
			s+=a[i];
		}
		cout << (s-M-m)/(n-2) << endl;
		cin >> n;
	}
	return 0;
}

C++: import java.util.Arrays;
import java.util.Scanner;
public class main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		while(true){
			int sum=0;
			int ave=0;
			int n=scan.nextInt();
			if(n==0){
				break;
			}
			int[] s = new int[n];
			for(int i = 0;i < n;i++){
				s[i]=scan.nextInt();
			}
			Arrays.sort(s);
			for(int i=1;i<n-1;i++){
				sum+=s[i];
			}
			ave=sum/(n-2);
			System.out.println(ave);
		}
	}
}

C++: #include <stdio.h>
int main(){
  int n,s,i,min=1000,max=3,sum=0,ave;
  while(1){
    scanf("%d",&n);
    if(n==0){
      break;
    }
    for(i=0;i<n;i++){
      scanf("%d",&s);
      if(s<min){
    min=s;
      } 
      if(s>max){
    max=s;
      }
      sum=sum+s;
    }
    sum=sum-max-min;
    ave=sum/(n-2);
    printf("%d\n",ave);
    sum=0;
    min=1000;
    max=3;
  }
  return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

//typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;
const int INF = 1000000000;

int main(){

	int n,s;
	while(cin >> n && !(n == 0)){
		int maxNum = 0;
		vector<int> nums;
		for(int i = 0; i < n; i++){
			int x;
			cin >> x;
			nums.push_back(x);
		}
		sort(nums.begin(),nums.end());
		int sum = 0;
		for(int i = 1; i < nums.size() - 1; i++){
			sum += nums[i];
		}
		cout << (int)((double)sum/(nums.size()-2)) << endl;
	}

	return 0;
}

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

int N, S;
int main() {
    while(cin >> N && N > 0) {
        int sum = 0;
        int maxi=0, mini=1000000;
        for (int i=0; i<N; ++i) {
            cin >> S;
            sum += S;
            if (S > maxi) {
                maxi = S;
            }
            if (S < mini) {
                mini = S;
            }
        }
        double ans = (sum - maxi - mini) / (N - 2);
        cout << ans << endl;
    }
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for (int i=(n)-1;i>=0;i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define REPS(i,f,n) for (int i=(f)-1;i>=(n);i--)
int dx[4] = {1, 0, 0, -1};
int dy[4] = {0, 1, -1, 0};

void slove(int s){
	int ma = s;
	int mi = s;

	ll sum = s;
	int tmp;
	cin >> tmp;
	while(tmp != 0){
		sum += tmp;
		ma = max(tmp, ma);
		mi = min(tmp, mi);
		cin >> tmp;
	}
	
	printf("%lld\n", sum - ma - mi);
	return;
}

int main(void){

	int s;
	rep(i, 110){
		scanf("%d", &s);
		slove(s);
	}

	return 0;
}

C++: #include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

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

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	while(1){
		ll n;
		cin >> n;
		if(n==0)break;
		ll maxk = 0;
		ll mink = INF;
		ll ans = 0;
		FOR(i,0,n){
			ll k;
			cin >> k;
			maxk = max(maxk,k);
			mink = min(mink,k);
			ans += k;
		} 
		ans -= (maxk+mink);
		cout << ans/(n-2) << endl;
	}
}

C++: while True:
    n = int(raw_input())

    if n == 0:
        break

    L = [int(raw_input()) for _ in range(n)]

    print (sum(L) - max(L) - min(L)) / (n - 2)

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main() {
  int i, n, sum, p[1001];
  while(1) {
    sum = 0;
    cin >> n;
    if(n==0) break;
    for(i=0; i<n; i++) {
      cin >> p[i];
      sum += p[i];
    }
    sort(p, p+n);
    sum -= p[0] + p[n-1];
    sum /= n-2;
    cout << sum << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int MIN,MAX,n,sum,a,i;
int main(){
while(true){
cin>>n;if(!n){break;}
MIN=10000000;
MAX=0;sum=0;
for(i=0;i<n;i++){cin>>a;MIN=min(MIN,a);MAX=max(MAX,a);sum+=a;}
cout<<(sum-MIN-MAX)/(n-2)<<endl;
}
}

C++: #include <stdio.h>

void B_sort(int data[], int n) {
  int tmp;
  for (int i = 0; i < n-1; i++) {
    for (int j = i+1; j < n; j++) {
      if (data[i] < data[j]) {
        tmp = data[i];
        data[i] = data[j];
        data[j] = tmp;
      }
    }
  }
}

int ave(int data[], int n) {
  int i;
  int sum = 0;
  int ave;
  for (i = 0; i < n; i++) {
    sum += data[i];
  }
  if (n >= 2) {
    ave = sum/(n-2);
  }
  else {
    ave = sum;
  }
  return ave;
}

int main(void) {
  int n[100] = {0};
  int s[100][100] =  { {0} };
  int i = 0, j = 0;
  
  while (1) {
    scanf("%d", &n[i]);
    if (n[i] == 0) {
      break;
    }
    for (j = 0 ; j < n[i]; j++) {
      scanf("%d", &s[i][j]);
    }
    i++;
  }
  
  i = 0;
  j = 0;

  while (n[i] != 0) {
    B_sort(s[i], n[i]);

    s[i][0] = 0;
    s[i][n[i]-1] = 0;

    printf("%d\n", ave(s[i], n[i]));
    i++;
  }

  return 0;
}