Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var (
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	for sc.Scan() {
		n, _ := strconv.Atoi(sc.Text())
		if n == 0 {
			break
		}
		scores := make([]int, n, n)
		for i := 0; i < n; i++ {
			sc.Scan()
			scores[i], _ = strconv.Atoi(sc.Text())
		}
		sort.IntSlice(scores).Sort()
		var sum = 0
		for i := 1; i < len(scores)-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

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;

		
	}
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    while(true){
        int N; cin >> N;
        int sum = 0;
        if(N == 0) break;
        vector<int> A(N);
        rep(i, N){
            cin >> A[i];
            sum += A[i];
        }
        sort(A.begin(), A.end());
        cout << (sum - A[0] - A[A.size()-1]) / (A.size()-2) << endl;
    }
    return 0;
}

C++: while true do

    max = -1
    min = 1001

    sum = 0

    n = gets.to_i


    n.times do
        v = gets.to_i
        min = v if v < min
        max = v if v > max
        sum += v
    end
    sum -= (min + max)
    p sum / (n-2)
end