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 <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

bool solve(){
  int n;
  int score[SIZE];
  
  scanf("%d",&n);

  if(n == 0) return false;
  
  for(int i=0;i<n;i++){
    scanf("%d",score+i);
  }

  sort(score, score+n);

  int sum = 0;

  for(int i=1;i<n-1;i++)
    sum += score[i];

  printf("%d\n",sum/(n-2));

  return true;
}

int main(){

  while(solve());
  
  return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
    while(1){
    int n,s[100],m=100000,M=0,sum=0;
    cin >> n;
        if(n==0)break;
    for(int i=0;i<n;i++)    cin >> s[i];
    for(int i=0;i<n;i++){
        sum+=s[i];
        m=min(m,s[i]);
        M=max(M,s[i]);
    }
    cout << (sum-M-m)/(n-2)<<endl;
    }
    return 0;
}

C++: #include <iostream>

int main()
{
  int n, s;
  while(std::cin >> n && n > 0){
    int average = 0;
    int max = 0;
    int min = 1000;
    for(int i=0; i<n; i++){
      int tmp;
      std::cin >> tmp;
      if(tmp > max){ max = tmp; };
      if(tmp < min){ min = tmp; };
      average += tmp;
    }
    average -= (max + min);
    std::cout << (average / (n - 2)) << std::endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int n;
long int ans;
int main() {
  for(;;) {
    scanf("%d", &n);
    if(n == 0) break;
    vector<int> v(n);
    for(int i = 0; i < n; ++i) scanf("%d", &v[i]);
    sort(begin(v), end(v));
    v[n - 1] = 0, v[0] = 0;
    for(int i = 0; i < n; ++i) ans+=v[i];
    ans /= n - 2;
    printf("%ld\n", ans);
    n = 0, ans = 0;
    v.clear();
  }
  return 0;
}

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

int main(){
	while(true){
		int n,sum=0;
		list<int> score; 
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			int tmp;
			cin>>tmp;
			score.push_back(tmp);
		}
		score.sort();
		score.pop_back();
		score.pop_front();
		for(list<int>::iterator it=score.begin();it!=score.end();++it)sum+=*it;
		cout<<sum/(n-2)<<endl;
	}
	return 0;
}

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

int main() {
int i,n,x,y,a[20],ans;
	while(1){
		scanf("%d",&n);
		if(n == 0)break;
		x = 0;
		y = 0;
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
		if(a[x] < a[i])x = i;
		if(a[y] > a[i])y = i;
		}
		ans = 0;
		for(i=0;i<n;i++){
			if(i == x)continue;
			if(i == y)continue;
			ans += a[i];
		}
		ans = ans / (n-2);
		printf("%d\n",ans);
	}
	return 0;
}

C++: #include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>
using namespace std;


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

C++: #include <bits/stdc++.h>
using namespace std;
int a[1010];

int main() {
    while(true) {
        int n; cin >> n;
        if(n == 0) break;
        for(int i=0; i<n; ++i) cin >> a[i];
        sort(a, a + n);
        int sum = 0;
        for(int i=1; i+1<n; ++i) sum += a[i];
        cout << sum / (n - 2) << '\n';
    }
}

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

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>
#define rep(i, a, b) for (int(i) = (a); i < (b); i++)
using namespace std;

using ll = long long;

typedef pair<int, int> P;

const int INF = 100000000;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;

ll pow_mod(ll x, ll y, ll mod)
{
	ll ans=1;
	for(;y>0;y>>=1){
		if(y&1)(ans*=x)%=mod;
		(x*=x)%=mod;
	}
	return ans;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	//問題文中の添え字が0-indexか1-indexか確認!
	while(1){
		int a;
		cin >> a;
		if(a==0){
			break;
		}
		vector<int> judge(a);
		rep(i, 0, a) cin >> judge[i];
		sort(judge.begin(), judge.end());
		int sum = judge[1];
		rep(i,2,a-1){
			sum += judge[i];
		}
		cout << sum / (a - 2) << "\n";
	}
	return 0;
}

C++: #include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;

#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

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

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

using namespace std;

int main(int, char**){
	int n;
	vector<int> ret;
	while(true){
		int n,buf;
		vector<int> scores;
		cin >> n;
		if(n == 0) break;

		for(int i = 0; i < n; ++i){
			cin >> buf;
			scores.push_back(buf);
		}
		scores.erase(max_element(scores.begin(),scores.end()));
		scores.erase(min_element(scores.begin(),scores.end()));
		ret.push_back( std::accumulate(scores.begin(), scores.end(), 0) / scores.size() );
	}

	for(int av : ret){
		cout << av << endl;
	}
	return 0;
}

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