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 <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a;
    while (cin>>n) {
        if (n==0) {
            break;
        } else {
            std::deque<int> deq;
            for (int i=0;i<n;i++) {
                cin>>a;
                deq.emplace_back(a);
            }
            sort(deq.begin(),deq.end());
            deq.erase(deq.begin(),deq.begin()+1);
            sort(deq.begin(),deq.end(),greater<int>());
            deq.erase(deq.begin(),deq.begin()+1);
            int sum=0;
            for (int j=0;j<deq.size();j++) {
                sum+=deq[j];
            }
            int ave=floor(sum/(n-2));
            cout<<ave<<endl;
        }
    }
}

C++: #ifndef _WIN32
#include<iostream>
#endif
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<string>
#include<stdlib.h>

using namespace std;
#define rep(i,n) for(auto i=(n)*0;i<n;i++)
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	cout << fixed << setprecision(30);
	int n;
	while (cin >> n, n){
		int top = 0, bottom = 1000,sum=0;
		rep(i, n){
			int s;
			cin >> s;
			sum += s;
			top = max(top, s);
			bottom = min(bottom, s);
		}
		cout << (sum - top - bottom)/(n-2) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <sstream>
#include <algorithm>

using namespace std;


int main () {
	while (true) {
		int n;
		cin >> n;
		if (n == 0) break;
		vector<int> v;
		int count = 0;

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

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

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

  }
  return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
  while(1){
    int n;
    cin >> n;
    if(n == 0)break;
    vector<int> array(n,0);
    int max_a = 0;
    int min_a = 10000;
    
    for(int i = 0;i < n;i++){
      int tmp;
      cin >> tmp;
      max_a = max(max_a,tmp);
      min_a = min(min_a,tmp);
      array[i] = tmp;
    }
    int sum = 0;
    for(int i = 0; i < n;i++){
      if(array[i] != max_a && array[i] != min_a)sum += array[i];
    }
    cout << (int)(sum / n-2) << endl;
  }
  return 0;
}

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

int main(){
    int n;
    while(cin >> n, n!=0){
        vector<int> score(n, 0);
        for(int i=0; i < n; i++) cin >> score[i];
        sort(score.begin(), score.end());
        int total = 0;
        for(int i=1; i < n-1; i++) total += score[i];
        cout << total/(n-2) << endl;
    }
}

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

int n;
int s[128];

int main() {
  for(;;) {
    scanf("%d", &n);
    if( n == 0 ) break;
    for(int i = 0; i < n; ++i) {
      scanf("%d", &s[i]);
    }
    std::sort(s, s + n);
    int total = 0;
    for(int i = 1; i < (n - 1); ++i) {
      total += s[i];
    }
    total /= (n - 2);
    printf("%d\n", total);
  }

  return 0;
}

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,a != 0){
    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 main()
{
loop:
  int min = 1 << 30, max = 0, sum = 0, n;
  cin >> n;
  if(!n)
    return 0;
  for(int i = 0; i < n; i++)
  {
    int tmp;
    cin >> tmp;
    max = max < tmp ? tmp : max;
    min = min > tmp ? tmp : min;
    sum += tmp;
  }
  cout << (sum - max - min) / (n - 2) << endl;
  goto loop;
}

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

int main(){
  int n,s[100],num,max=s[0],min=s[0];
  
  while(true){
    
  cin>>n;
  if(n == 0)break;
      num=0;
    
  for(int i=0;i<n;i++){
    cin>>s[i];
      
    if(max<s[i])max=s[i];
    if(max>s[i])min=s[i];
       
    num += s[i];
  }
  num = (num-max-min)/n;
    cout<<num<<endl;
    

    
  }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
//#define scanf scanf_s

int main()
{
	int n;
	while (cin >> n,n)
	{
		int max = 0; int min = INF;
		int sum = 0;
		REP(i, n)
		{
			int a;
			cin >> a;
			sum += a;
			if (a > max) max = a;
			if (a < min) min = a;
		}
		sum = sum - max - min;
		cout << sum / (n - 2) << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;

int judge(int n){
  int max=-1, min=1001, sum=0;
  vi s(n);
  rep(i, n){
    cin >> s[i];
    sum+=s[i];
    if(s[i]>max)max=s[i];
    if(s[i]<min)min=s[i];
  }
  return (sum-max-min)/(n-2);
}

int main(){
  int cnt=0;
  vi ans(20);
  rep(i, 20){
    int n;
    cin >> n;
    if(n==0)break;
    ans[i]=judge(n);
    cnt++;
  }

  rep(i, cnt){
    if(ans[i]==-1)break;
    cout << ans[i] << endl;
  }

  return 0;
}

C++: #include <iostream>
#include<algorithm>
using namespase std;
int main(){
int n;
cin>>n;
int sum =0;
int ma =0;
int mi =100000;
int cnt =0;
for(int i=0;i<n;i++){int s;cin>>s;sum+=s;ma =max(ma,s);mi=min(mi,s);cnt++;}
cout<<(sum-mi-ma)/(cnt-2)<<endl
}