Go: package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	for n != 0 {
		arr := make([]int, n)
		for i := range arr {
			fmt.Scan(&arr[i])
		}
		sort.Ints(arr)

		sum := 0
		for i := 1; i < len(arr)-1; i++ {
			sum += arr[i]
		}
		fmt.Println(sum / (n - 2))
		fmt.Scan(&n)
	}
}

C++: #include <iostream>
using namespace std;
int larger(int x,int y) {
	int z = 0;
	if (x > y)z = x;
	else z = y;
	return z;
}
int smaller(int x, int y) {
	int z = 0;
	if (x < y)z = x;
	else z = y;
	return z;
}
int main(void) {
	int s = 1;
	while (s == 1) {
		int sinsa, a[100], sum = 0, ave;
		cin >> sinsa;
		if (sinsa == 0)s = 2;
		for (int i = 0; i < sinsa; i++) {
			cin >> a[i];
		}
		int n = a[0];
		for (int i = 0; i < sinsa; i++) {
			n = larger(n, a[i]);
		}
		int m = a[0];
		for (int i = 0; i < sinsa; i++) {
			m = smaller(m, a[i]);
		}
		for (int i = 0; i < sinsa; i++) {
			sum += a[i];
		}
		sum = sum - n - m;
		ave = sum / (sinsa - 2);
		cout << ave;
	}

	return 0;

}

C++: #include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<cassert>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl

using namespace std;


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

	}


	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<climits>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define PII pair<int,int>
#define PCC pair<char,char>
#define PCI pair<char,int>
#define PIC pair<int,char>
#define MP make_pair
#define DEBUG(x) cout<<#x<<": "<<x<<endl;

int main()
{
	int n;
	for (; cin >> n, n != 0;)
	{
		int Min = INF;
		int Max = -1;
		int sum = 0;
		REP(i, n)
		{
			int temp;
			cin >> temp;
			Min = min(Min, temp);
			Max = max(Max, temp);
			sum += temp;
		}
		sum =sum - Min - Max;
		int ans = sum / (n-2);
		cout <<ans<< endl;
	}
	return 0;
}

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

int main() {
	int n, a[100];
	while(1){
		cin >> n;
		if(n==0) break;
		int min, max, sum, avg;
		for(int i=0; i<n; i++)
			cin >> a[i];
			min = max = sum = a[0];
		for(int j=1; j<n; j++){
			sum += a[j];
			if(min>a[j]) min = a[j];
			if(max<a[j]) max = a[j];
		}
		avg = (sum-max-min)/(n-2);
		cout << avg << endl;
	}
	return 0;
}

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

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

        int s[n];
        for(int i=0;i<n;i++){
            cin>>s[i];
        }

        int max=0,min=1000;;

        for(int i=0;i<n;i++){
            if(s[i]>max)max=s[i];
            else if(s[i]<min)min=s[i];
        }
        
        int sum=0;
        for(int i=0;i<n;i++){
            sum +=s [i];
        }


        sum -=max;
        sum -=min;

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

    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n,m;
	int a,b,c;
	int i,j,k;
	int s=0;
	while(cin>>n){
		if(!n)break;
		b=0,c=1e5,s=0;
		for(i=0;i<n;i++){
			cin>>a;
			if(b<a)b=a;
			if(a<c)c=a;
			s+=a;
		}
		s-=b+c,n-=2;
		s/=n;
		cout<<s<<endl;
	}
}

C++: #include<iostream>
//#include<fstream>

using namespace std;

const int calc(int*, int);


int main(){
//	ifstream fin("in.txt");

	int data[20] = {};
	int count = 0;
	while (true){
		cin >> count;
		if (count == 0)break;
		for (int i = 0; i < count; i++){
			cin >> data[i];
		}

		for (int i = 1; i < count; i++){
			for (int j = i; j > 0; j--){
				if (data[j - 1] > data[j]){
					int tmp = data[j];
					data[j] = data[j - 1];
					data[j - 1] = tmp;
				}
			}
		}
		cout << calc(data, count) << endl;
	}

	return 0;
}

const int calc(int* a, int count){
	if (count <= 0)return 0;

	int ave = 0;

	for (int i = 1; i < count - 1; i++)ave += a[i];
	return ave / (count - 2);
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n;
  while(scanf("%d",&n),n){
    vector<int> v(n);
    for(int i=0;i<n;i++){
      int tmp;
      scanf("%d",&tmp);
      v[i]=tmp;
    }
    double ans=0;
    sort(v.begin(),v.end());
    for(int i=1;i<v.size()-1;i++){
      ans+=(double)v[i];
    }
    printf("%d\n",(int)(ans/(v.size()-2)));
  }
  return 0;
}

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

int main(void)
{
    int sum, n, mmin, mmax, in;
    while(1) {
        sum = 0; mmax = -1; mmin = 114514810;
        cin >> n;
        if(n == 0) break;
        for(int i=0; i<n; i++) {
            cin >> in;
            sum += in;
            mmax = max(mmax, in);
            mmin = min(mmin, in);
        }
        sum = sum - mmax - mmin;
        cout << sum / n << endl;
    }
    
    return 0;
}

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

using namespace std;

int main(){
	double res;
	for(int n; cin >> n, n; cout << (int)res << endl){
		res = 0.0;
		vector<int> l;
		for(int i = 0; i < n; i++){
			int buf; cin >> buf;
			l.push_back(buf);	
		}
		sort(l.begin(), l.end());
		for(int i = 1; i < l.size() - 1; i++){res += (double)l[i];}
		res /= (double)(l.size() - 2);
	}
	return 0;
}

C++: #include<bits/stdc++h>
typedef long long ll;
using namespace std;
int main(){
  ll N;
  ll s[1100];
  ll sum=0;
  while(N){
  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;
  cin>>N;
}
}

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

vector<int> v;


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

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

int main(){
    while (1){
	int n;
	vector<int> s;
	
	cin >> n;
	if (n == 0) break;
	int t;
	for (int i = 0; i < n; i++){
	    cin >> t;
	    s.push_back(t);
	}
	sort(s.begin(), s.end());

	int score = 0;
	for (int i = 1; i < s.size() - 1; i++){
	    score += s[i];
	}
	score /= s.size() - 2;

	cout << score << endl;
    }
}

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    for(;;){
        int a,n,s=0,max=0,min=INT_MAX;
        cin>>n;
        if(n==0) break;
        for(int i = 0; i < n; i++){
            cin>>a;
            s+=a;
            if(max<a) max=a;
            if(min>a) min=a;
        }
        cout<<(s-max-min)/n<<endl;
    }
    return 0;
}

C++: // PKU 3325
#include<algorithm>
#include<cstdio>
#define rep( i, a ) for( int i = 0; i != (a); ++i )

int main()
{
	int n;
	while( scanf( "%d", &n ), n )
	{
		int ma = 0, mi = 1 << 30, sum = 0;
		rep( i, n )
		{
			int a;
			scanf( "%d", &a );

			sum += a;
			ma = std::max( ma, a );
			mi = std::min( mi, a );
		}

		printf( "%d\n", (sum - ma - mi) / (n - 2) );
	}

	return 0;
}

C++: int main()
{
    int n;
    while(1){
        cin >> n;
        if(n == 0) break;
        int max = -1, min = 10000, sum = 0, score = 0, ans = 0;
        for(int i = 0; i < n; i++){
            cin >> score;
            sum += score;
            if(score > max) max = score;
            if(score < min) min = score;
        }
        sum -= max + min;
        ans = sum / (n - 2);
        cout << ans << endl;
    }
    return 0;
}