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 <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;
}

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

using namespace std;

int main() {
	int n;
	int total;
	int ave;

	while (1) {
		int tmp;
		vector<int> v;
		cin >> n;
		if (n == 0)break;

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

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

		total = 0;
		for (int i = 0; i<n; i++) {
			total += v[i];
		}

		total = total - (v[0] + v[n - 1]);
		ave = total / (n - 2);

		cout << ave << endl;

		
	}
}