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()
{
    while (true)
    {
        int x;
        std::cin >> x;
        if (x == 0)
        {
            break;
        }
        long sum = 0;
        long max = 0;
        long min = 1000;
        for (int i = 0; i < x; i++)
        {
            long j;
            std::cin >> j;
            max = std::max(max, j);
            min = std::min(min, j);
            sum += j;
        }
        sum -= (min + max);
        std::cout << sum / (x - 2) << std::endl;
    }
}

C++: #include <iostream>
#include <numeric>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
#define ll long long
#define bl bool
#define nn printf("\n");
#define mod 1000000007

using namespace std;

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

	while (1)
	{
		int num = 0; cin >> num;
		if (num == 0) { break; }
		vector<int> scr(num, 0);
		rep(i, num){ cin >> scr[i]; }
		int ans = 0;
		ans = accumulate(all(scr), 0) - *max_element(all(scr)) - *min_element(all(scr));
		printf("%d\n", ans / (num - 2));
	}

	return 0;
}

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

int n,s;

int main(){
	int i;
	while( cin >> n ){
		if( !n )break;
		
		int ans = 0,mx = 0,mn = 10000;
		for( i = 0; i < n; i++ ){
			cin >> s;
			ans += s;
			mx = max( mx, s );
			mn = min( mn, s );
		}
		ans -= mx+mn;
		cout << ans/(n-2) << endl;
	}
	return 0;
}

C++: #include <stdio.h>
#include <climits>
#include <iostream>
using namespace std;
int main(){
  int n,work;
  while(1){
    int sum = 0,max=0,min=INT_MAX;
    cin >> n;
    if(n==0) break;
    for(int i=0;i<n;i++){
      cin >> work;
      max = (max < work) ? work : max;
      min = (min > work) ? work : min;
      sum+=work;
    }
    sum -=max;
    sum -=min;
    printf("%d\n",sum/(n-2));
  }

  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

int n,score[111],ave;

void solve(){
  ave = 0;
  cin>>n;

  if(n == 0) exit(0);

  REP(i,n){
    cin>>score[i];
  }

  sort(score,score+n);

  FOR(i,1,n-1){
    ave += score[i];
  }
  ave /= (n-2);

  cout<<ave<<endl;
}


int main(){

  while(1){
    solve();
  }

  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) v.begin(), v.end()
template<class T> using V = vector<T>;

int main(){
  int n;
  while(cin>>n,n){
    V<int> a(n);
    REP(i,n) cin >> a[i];
    sort(ALL(a));
    int ans = accumulate(a.begin()+1,a.end()-1,0);
    cout << ans/(n-2) << endl;
  }
}

C++: #include "bits/stdc++.h"
using namespace std;
int main() {
	int n;
	while (cin >> n,n) {
		int Sum = 0;
		int Max = -1;
		int Min = 1001;
		for (int i = 0; i < n; i++) {
			int a; cin >> a;
			Sum += a; Max = max(Max, a); Min = min(Min, a);
		}
		Sum -= Max + Min;
		cout << Sum / (n - 2) << endl;
	}
}

C++: #include <iostream>
#include <utility>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

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

const int INF = 1 << 28;

int main()
{
  int n;
  while(cin >> n, n) {
    int ax = 0;
    int in = INF;
    int sum = 0;
    rep(i, n) {
      int m;
      cin >> m;
      ax = max(ax, m);
      in = min(in, m);
      sum += m;
    }
    sum -= ax;
    sum -= in;
    sum /= n - 2;

    cout << sum << endl;
  }
  return 0;
}

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

int main()
{
    int n,s;
    int sum = 0;
    std::vector<int> v;
    cin >> n;

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

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

    for(int i = 1; i < v.size() -1 ; i++)
    {
        sum += v[i];
    }
    int ave = sum / (v.size() - 2);
    cout << ave <<endl;
    return 0;
}

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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {
	while (1) {
		int n;
		int s[101];
		int mini = INF;
		int maxi = -1;
		int total = 0;

		cin >> n;
		if (n == 0) {
			break;
		}
		FOR(i, 1, n) {
			cin >> s[i];
			if (maxi < s[i]) {
				maxi = s[i];
			}
			else if (mini > s[i]) {
				mini = s[i];
			}
			else {
				total += s[i];
			}
		}
		cout << total / (n - 2) << endl;
	}


}

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

#define ll long long int
#define ld long long double
#define reps(i,f,n) for(int i=f;i<n;i++)
#define rep(i,n) reps(i,0,n)
#define m1 cout<<"move1"<<endl
#define m2 cout<<"move2"<<endl
#define m3 cout<<"move3"<<endl
#define m4 cout<<"move4"<<endl

int main(){
  ll sum=0;
  int N=0;
  int max_v= -1;
  int min_v= 10000;
  int a;
  int b;
  // m2;
  while(cin>>a){
    N = a;
    // cout<<a<<endl;
    // m1;
    for(int i=0;i<N;i++){
      cin>>b;
      max_v=max(max_v,b);
      min_v=min(min_v,b);
      sum += b;
      // cout<<sum<<endl;
       }
    sum = sum - max_v - min_v;
    cout<<sum / ( N -2)<<endl;
    max_v=-1;
    min_v=1000;
    sum =0;
  }
  return 0;

}

C++: #include <iostream>
using namespace std;
int N, A[1024],Max,Min,Sum;

int main(){
 while(cin >> N && N>0){
 Max=0;
 Min=1000;
  for (int i=0; i<N; ++i)
    cin >> A[i];
  for (int j=0; j<N; ++j){
	if(A[j]>Max) Max=A[j];
    }
  for (int k=0; k<N; ++k){
	if(A[k]<Min) Min=A[k];
	}
  for (int l=0; l<N; ++l){
    Sum += A[l];
	}
  cout<< (Sum-Max-Min)/(N-2) << endl;
  Sum=0;
 }
}

C++: #include<iostream>
using namespace std;
int main(){
int judge;
int maxscore =0;
int minscore =0;
int maxnum=0;
int minnum=0;
cin >> judge;
int score[judge];
	for(int i=0; i<judge-1; i++){
	cin >> score[i];
		if(score[i] > maxscore){
		maxscore = score[i];
		i=maxnum;
		}
		if(score[i] < minscore){
		minscore = score[i];
		i = minnum;
		}
	}
score[maxnum] = 0;
score[minnum] = 0;
int lastscore = 0;
for(int j=0;j<judge-1;j++){
lastscore += score[j];
}
lastscore = lastscore/(judge - 2);
cout << lastscore <<endl;
return 0;
}

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

using namespace std;

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

		vector<int> j(n);
		for(int i = 0; i < n; ++i)cin >> j[i];
		sort(j.begin(), j.end());
		int ans = 0;
		for(int i = 1; i < n-1; ++i){
			ans += j[i];
		}
		ans /= j.size()-2;
		cout << ans << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
  ll N;
  ll s[1100];
  ll sum=0;
  cin>>N;
  while(N){
  for(ll i = 0; i < N; ++i){
      cin >> s[i];
  }
  sort(s,s+N);
  for(ll i = 1; i < N-1; ++i){
    sum+=s[i];
  }
  cout<<sum/(N-2)<<endl;
  cin>>N;
  }
}