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 main() {
	int n, max, min, s;
	long sum;

	while (true) {
		cin >> n;
		sum = max = 0;
		min = 1000;

		if (n == 0)	break;

		for (int i = 0; i < n; i++) {
			cin >> s;
			if (s < min)	min = s;
			if (s > max)	max = s;
			sum += s;
		}
		sum -= (min + max);
		cout << sum / (n - 2) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while(cin >> n, n)
    {
        vector<int> v(n);
        for(int i = 0; i < n; i++) cin >> v[i];
        sort(v.begin(), v.end());
        int ans = 0;
        for(int i = 1; i < n - 1; i++)
        {
            ans += v[i];
        }
        ans /= n - 2;
        cout << ans << endl;
    }
    return 0;
}

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

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

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
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;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	int n,i,s,sum;
	vi v;
	while(1){
		cin>>n;
		if(n==0)break;
		
		v.clear();
		rep(i,n){
			cin>>s;
			v.push_back(s);
		}
		sort(v.begin(),v.end());
		sum=0;
		for(i=1;i<n-1;i++){
			sum+=v[i];
		}
		cout<<sum/(n-2)<<endl;
	}
	
	
	
	
	
	
//////////////////////////////////////////////////////
return 0;}

C++: #include<iostream>
using namespace std;
int main(){
while(true){
int n;
cin >> n;
if(n == 0)return 0;
int a[n];
for(int i = 0; i < n; i++)
cin >> a[i];

int max = 0;
int min = 1000;
int sum = 0;

for(int i = 0 ; i < n ; i++){
	if(a[i] > max)
	max = a[i];
	if (a[i] < min)
	min = a[i];
	sum += a[i];
}
cout << (sum-max-min)/(n-2);

}
}

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

int n;

int main(){
  int ave;
  while(cin >> n && (n > 0)){
  int a[100];
  int sum = 0;
  for (int i = 0; i <= n-1; i++){
   cin >> a[i];
   }
   sort(a, a+n);
   for (int j=1; j <= n-2; j++){
     sum += a[j];
	 }
   ave = floor(sum / (n-2));
   cout << ave << endl;
	}
 }

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

using namespace std;

int main(){
  int n;
  while(cin>>n){
    if(n==0)break;
    vector<int> score(n);
    for(int i=0;i<n;i++)cin>>score[i];

    vector<int>::iterator minIt = min_element(score.begin(),score.end());
    int minIndex = distance(score.begin(),minIt);
    score.erase(score.begin()+minIndex-1);

    vector<int>::iterator maxIt = max_element(score.begin(),score.end());
    int maxIndex = distance(score.begin(),maxIt);
    score.erase(score.begin()+maxIndex-1);

    int sum = accumulate(score.begin(),score.end(),0);
    cout << sum/score.size() << endl;
  }
  return 0;
}

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

using namespace std;

int main(void){

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

  return 0;
}

C++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <math.h>
#include <string.h>
#include <stack>
#include <cctype>

using namespace std;


int main(){

	while(1){
		int n,s,sum,max,min;

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

		sum=0;
		for(int i=0;i<n;i++){
			cin>>s;
			if(i==0){
				max=s,min=s;
			}
			if(s<min) min=s;
			if(s>max) max=s;
			sum+=s;
		}
		cout<<(sum-max-min)/(n-2)<<endl;
	}	

	return 0;
}

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

int main() {
    int N;
    while (1) {
        cin >> N;
        if (N == 0) break;
        vector<int> score(N);

        for (int i = 0; i < N; i++) {
            cin >> score[i];
        }
        sort(score.begin(), score.end());

        int h = 0;
        for (int i = 1; i < N - 1; i++) {
            h += score[i];
        }
        cout << h / (N - 2) << endl;
    }
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main() {
    int n,input;
    while (1){
        scanf("%d", &n);
        if (n==0){
            break;
        }
        int sum=0,max=0,min=1001;
        for (int i;i<n;i++) {
            cin >> input;
            sum = sum+input;
            if (max < input) max = input;
            if (min > input) min = input;
        }
        printf("%d\n", (sum-max-min)/(n-2));
    }
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>=0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = 3.141592653589793;

int n;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (cin >> n,n) {
        int  s[105]={};
        rep(i,n) cin >> s[i];
        sort(s,s+n);
        int ans=0;
        rep2(i,1,n-1) ans+=s[i];
        cout << ans/(n-2) << endl;
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
        int n, s ;
	while (cin >> n && n > 0){
		int large = 0;
		int small = 1000;
		int sum = 0;
  		for (int i=0; i>n; ++i){
			cin >> s;
			sum = sum + s;
			if (large < s) {large = s}
			if (small > s) {small = s}
		}
		int ans = 0;
		ans = (sum - large - small) / (n - 2);
		cout << ans << endl ;
	}
}

C++: #include <stdio.h>
int max(int a,int b){
if(a>b)return a;
return b;
}
int min(int a,int b){
if(a>b)return b;
return a;
}
int main(){
int n,top,bot,tot,temp;
while(1){
scanf("%d",&n);
if(n==0)return 0;
scanf("%d",&top);
tot=bot=top;
for(int i=1;i<n;i++){
scanf("%d",&temp);
tot+=temp;
top=max(top,temp);
bot=min(bot,temp);
}
printf("%d\n",(tot-top-bot)/n);
}
}