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>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;

int main(){
    
    while(true){
        int n;
        cin >> n;
        
        if(n == 0) break;
        
        vector<int> a(n);
        int minv = 1001;
        int maxv = -1;
        int sum = 0;
        rep(i,n){
            cin >> a[i];
            minv = min(minv,a[i]);
            maxv = max(maxv,a[i]);
            sum += a[i];
        }
        sum = sum - minv - maxv;
        sum /= (n-2);
        
        cout << sum << endl;
    }
}

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

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

#define var auto
#define long long long
#define ll long
#define Max std::max
#define Min std::min
#define Abs std::abs

void Solve();

using namespace std;

int main() {
    while (true) {
        Solve();
    }
}

void Solve() {
    int n;
    cin >> n;
    if (n == 0) exit(0);
    long sum = 0;
    long max = INT32_MIN;
    long min = INT32_MAX;
    for (int i = 0; i < n; ++i) {
        long a;
        cin >> a;
        sum += a;
        max = Max(max, a);
        min = Min(min, a);
    }
    cout << (sum - max - min) / (n - 2) << endl;
}

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

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

}

C++: #include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){

    while(true){
        int n;
        cin >> n;

        if(n == 0){
            break;
        }

        vector<int> a(n);
        rep(i, n) cin >> a[i];

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

        int s = 0;
        for(int i = 1; i < n-1; i++){
            s += a[i];
        }
        cout << s / (n-2) << endl;
    }

    return 0;
}

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

int N, S;
int main() {
	while(cin >> N && N > 0) {
		int sum = 0;
		int largest = 0;
		int smallest = 1000;

		for(int i = 0; i < N; i++) {
			cin >> S;
			sum += S;
			if(S > largest) largest = S;
			if(S < smallest) smallest = S;
		}

		sum = sum - largest - smallest;
		//cout << "laegest:" << largest << endl;
		//cout << "smallest:" << smallest << endl;
		cout << sum / (N-2) << endl;

	}
}

C++: #include <iostream>
using namespace std;
int main(){
	int n,i,t,a,ma,mi;
	while(cin>>n,n){
		t=ma=0,mi=1000;
		for(i=0;i<n;i++)cin>>a,t+=a,ma=max(ma,a),mi=min(mi,a);
		cout<<(t-ma-mi)/(n-2)<<endl;
	}
}

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

int totalizer(vector<int>& data, int& dataLength) {
	int total = 0;
	int max = data[0];
	int min = data[0];

	for (int i = 0; i < dataLength; ++i) {
		total += data[i];

		if (data[i] > max) max = data[i];
		if (data[i] < min) min = data[i];
	}
	total -= (max + min);
	return total / (dataLength - 2);
}

int main() {
	vector<int> v(100);

	int n;
	cin >> n;

	while (n != 0) {
		for (int i = 0; i < n; ++i) {
			cin >> v[i];
		}
		cout << totalizer(v, n) << endl;
		cin >> n;
	}

	return 0;
}

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

int main() {int n,i,a,b,max,min,sum,answer;
while(cin >> n, n ) {
i =2;
cin >> a;
max=a;
min=a;
sum =a;
while(i<=n)
{cin >> b;
if(b>max){max=b;}
if(b<min){min=b;}
sum = sum+b;
i++;
}
//if(b==0){break;}
answer=(sum-max-min)/(n-2);
cout << answer << endl;
}
	// your code goes here
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int n;
    while(1){
        cin>>n;
        if(n==0)break;
        vector<int> s(n);
        for(int i=0;i<n;i++){
            cin>>s[i];
        }
        sort(s.begin(),s.end());
        long long ans=0;
        for(int i=1;i<n-1;i++){
            ans+=s[i];
        }
        cout<<ans/(n-2)<<endl;
    }
    return 0;
}

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

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

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

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

using namespace std;

int n, x;
int main(){
	while(cin >> n, n){
		int mi = 1 << 30, ma = -1 << 30, res = 0;
		for(int i = 0;i < n;i++){
			cin >> x;
			res += x;
			mi = min(mi, x);
			ma = max(ma, x);
		}
		cout << (res - mi -ma) / (n - 2) << endl;
	}
	return 0;
}

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

using namespace std;

int main(){
  int n;

  while(cin>>n,n){
    vector<int> s;
    int t;
    int total=0;
    int cnt=0;
    
    for(int i=0;i<n;++i){
      cin>>t;
      s.push_back(t);
    }

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

    for(int i=1;i<n-1;++i){
      total+=s[i];
      cnt++;
    }

    cout<<total/cnt<<endl;
  }
}

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

int main() {
	int N;

	while(cin >> N, N) {
		vector<int> scores;
		int score;
		for(int i=0; i < N; i++) {
			cin >> score;
			scores.push_back(score);
		}

		sort(scores.begin(), scores.end());
		int sums = 0;
		for(int i=1; i<scores.size()-1; i++) {
			sums+=scores[i];
		}
		int ans = sums/(scores.size()-2);
		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

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

int main(){
	int n,sum,max,min;
	while(cin>>n&&n>0){
		int S;
		min=1000000000;
		max=0;
		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;
	}
	return 0;
}