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;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> res;
    while(1){
        int n;
        deque<int> rec;
        cin >> n;
        if(n == 0) break;
        for(int i=0;i<n;i++){
            int tmp;
            cin >> tmp;
            rec.push_back(tmp);
        }
        sort(rec.begin(), rec.end());
        rec.pop_front();
        rec.pop_back();
        int ans = 0;
        for(int i=0;i<n-2;i++){
            ans += rec[i];
        }
        res.push_back(ans/(n-2));
    }
    for(int i=0;i<res.size();i++) cout << res[i] << endl;
    return 0;
}

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

int main() {
int n;
while(cin>>n){
	if(n==0){
		break;
	}
	int sum=0,max=0,min=1000,score;
	for(int k=0;k<n;k++){
		cin>>score;
		sum=sum+score;
		if(score>max){
			max=score;
		}
		if(score<min){
			min=score;
		}
	}
	cout<<(sum-max-min)/(n-2)<<endl;
}
	return 0;
}

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

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

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

int main(int argc, char const *argv[]) {
    vector<int> vc;
    while(true){
        int n;cin>>n;
        if(n==0)break;
        int max,min;
        int sum=0;
        for(int i=0;i<n;i++){
            int score;cin >> score;
            if(i==0){
                min = score;
                max = score;
            }
            if(max < score)max = score;
            if(min > score)min = score;
            sum+=score;
        }
        sum -= max;
        sum -= min;
        int avg = sum/(n-2);
        cout << avg << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n1;
	cin >> n1;
		int a[n1] = { 0 };
		for (int i = 0; i < n1; i++){
			cin >> a[i];
		}
		sort(a, a + n1);
		a[0] = { 0 };
		a[n1 - 1] = { 0 };
		for (int i2 = 1; i2 < n1; i2++){
			a[0] += a[i2];
		}
		cout << a[0] / (n1 - 2) << endl;
return 0;
		
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define INF (1 << 30)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int main() {
	int N;
	while(scanf("%d", &N), N) {
		int res = 0;
		int maxi = -1, mini = INF;
		int a;
		rep(i, N) {
			scanf("%d", &a);
			res += a;
			maxi = max(maxi, a);
			mini = min(mini, a);
		}
		res = res - (maxi + mini);
		double ans = (double)res / (N - 2) * 10;
		res = (int)(ans / 10);
		printf("%d\n", res);
	}
	return 0;
}

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

int main(){


  int n;

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

    //テ・ツ?・テ・ツ環?
    int point[200];
    for(int i = 0; i < n ; i++){
      cin >> point[i];
      cout << point[i] << " ";
    } 
    cout << endl;

    //max
    int max = -1;
    for(int i = 0 ; i < n ; i++){
      if(point[i] > max)
	max = point[i];
    }
    for(int i = 0 ; i < n ; i++){
      if(point[i] == max){
	point[i] = -1;
	break;
      }
    }

    //min
    int min = 10000;
    for(int i = 0 ; i < n ; i++){
      if(point[i] < min && point[i] != -1 )
	min = point[i];
    }
    for(int i = 0 ; i < n ; i++){
      if(point[i] == min){
	point[i] = -1; 
	break;     
      }
    }

    int ans = 0;
    for(int i = 0; i < n ; i++){
      if(point[i] > -1)
	ans += point[i];
   cout << point[i] << " ";
    }
    ans = ans / (n-2);
    cout << ans << endl;

  }

  return 0;
}

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

int main(){
int n;
while(cin >>n){
	if(n == 0) break;
	vector<int> vec;
	int tmp, max, min;
	cin >>tmp;
	vec.push_back(tmp);
	max = tmp;
	min = tmp;
	bool maxb = true, minb = true;
	for(int i = 1; i < n; i++){
		cin >>tmp;
		vec.push_back(tmp);
		if(tmp < max) max = tmp;
		if(tmp > min) min = tmp;
	}
	int sum = 0;
	for(int i = 0; i < vec.size(); i++){
	if(vec[i] == max && maxb){
		maxb = false;
	} else if(vec[i] == min && minb){
		minb =false;
	} else{
		vec[i] += sum;
	}
	cout <<sum <<endl;
	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,s[100],m,M,sum=0;
    cin >> n;
    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 << (double)(sum-M-m)/(n-2)<<endl;
    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
using namespace std;

int main(){
	int N,S;
	while(cin>>N,N){
		int sum=0,min_=INT_MAX,max_=INT_MIN;
		for(int i=0;i<N;i++){
			cin>>S;
			min_ = min(min_,S);
			max_ = max(max_,S);
			sum += S;
		}
		printf("\t%d\n",(sum-min_-max_)/(N-2));
	}
	return 0;
}

C++: #include <iostream>

int main()
{
    int n, s = 0;
    while (std::cin >> n && n > 0) {
        int max, min, sum = 0;
        std::cin >> s;
        max = s;
        min = s;
        sum += s;

        for (int i = 0; i < n - 1; i++) {
            std::cin >> s;
            if (s > max)
                max = s;
            if (s < min)
                min = s;
            sum += s;
        }
        std::cout << (sum - max - min) / (n - 2) << '\n';
    }

    return 0;
}

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

int main(){
  int n,s,sum,ma,mi;

  while(cin >> n, n){
    cin >> sum;
    ma = mi = sum;
    for(int i=1;i<n;i++){
      cin >> s;
      sum += s;
      ma = max(ma,s);
      mi = min(mi,s);
    }

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

C++: #include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<random>
#include<string>
typedef long long ll;
using namespace std;
int main(){
  ll N;
  ll s[1100];
  ll sum=0;
  ll t=0;
  while(t<=20){
  t++;
  cin >> 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;
}
}