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 <iostream>

using namespace std;

int main(){
    int n,s[1000], i;
    while (cin >> n && n>0){
        int sum = 0, maximum =0, minimum = 10000;
        for (i = 0; i > n; i++){
            cin >> s[i];
            sum += s[i];
        }
        for (i = 0; i > n; i++){
            maximum = max(maximum, s[i]);
            minimum = min(minimum, s[i]);
        }
        cout << (sum - maximum - minimum)/(n -2) << endl;
    }
}

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

int main(){
  int n,s[100],num,max=s[0],min=s[0];
  
  do{
  cin>>n;    
    num=0;
    
  for(int i=0;i<n;i++){
    cin>>s[i];

    if(max<s[i])max=s[i];
    if(max>s[i])min=s[i];
       
    num += s[i];
  }
  num = (num-max-min)/n;
    cout<<num<<endl;

  }while(n != 0);
  return 0;
}

C++: int maximum = 0;
    for (int i=1; i<S; ++i)
        for (int j=i; j<S; ++j)
            if (tax(X,i)+tax(X,j) == S) // (*)
              maximum = max(maximum, tax(Y,i)+tax(Y,j));

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

int main() {
    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());
        cout << accumulate(v.begin()+1, v.end()-1, 0) / (v.size()-2) << endl;
    }
}

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a,n;
    for(;;){
        vector<int> num;
        cin>>n;
        if(n==0) break;
        for(int i = 0; i < n; i++){
            cin>>a;
            num.push_back(a);
        }
        sort(num.begin(), num.end());
        num.erase(num.begin());
        num.pop_back();
        int sum=0;
        for(int x : num){
            sum+=x;
        }
        sum/=num.size();
        cout<<sum<<endl;
    }
    return 0;
}

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

	return 0;

C++: #include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

int main(){
    int n;
    while(cin>>n, n){
        int sum=0, smin=1000, smax=0;
        for(int i=0; i<n; i++){
            int s; cin>>s;
            sum+=s;
            chmin(smin, s);
            chmax(smax, s);
        }
        sum-=smin;
        sum-=smax;
        
        cout << sum/(n-2) << endl;
    }
}

C++: #include <iostream>
#include <cstdio>
#define INF 1e+18
#define int long long
using namespace std;

signed main(){
	int n;
	while(cin >> n,n){
		int mi = INF,ma = 0,sum = 0;
		for(int i = 0;i < n;i++){
			int t;
			cin >> t;
			mi = min(t,mi);
			ma = max(t,ma);
			sum += t;
		}
		sum -= (mi + ma);
		cout << sum / (n - 2) << endl;
	}
	return 0;
}

C++: //#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <utility>
using namespace std;
#define INF 100000005
#define MAX 200005

int a[1001];
int main(){
	int n, sum;
	while(cin >> n, n){
		sum = 0;
		for(int i = 0;i < n;i++){
			cin >> a[i];
			sum += a[i];
		}
		sum -= *max_element(a, a+n);
		sum -= *min_element(a, a+n);
		cout << sum/(n-2) << endl;
	}
	return 0;
}

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

int solve() {
    int N;
    cin >> N;
    if(N==0) return 0;
    vector<int> datas;
    datas.resize(N);
    for(int i=0; i<N; i++) {
        cin >> datas[i];
    }
    sort(datas.begin(), datas.end());
    int sum = 0;
    int counter = 0;
    for(auto itr=datas.begin()+1; itr!=datas.end()-1; itr++) {
        sum += *itr; counter++;
    }
    cout << sum/counter << endl;
    return 1;
}

int main() {
    while(solve()) {}
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
typedef long long i64;
int main(){
  while(true){
    int n;
    vector<int> a;
    cin >> n;
    rep(i,n){
      int b;
      cin >> b;
      a.push_back(b);
    }
    sort(a.begin(),a.end());
    int total=0;
    repi(i,1,n-1){
      total+=a[i];
    }
    cout << total/(n-2) << endl;;
  }
  return 0;
}

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

typedef long long int64;
typedef int int32;
typedef char int8;

#define rep(i,j) for(int i=0;i<j;i++)
#define repeat(i,j,k) for(i=(j),i<(k);i++)
#define repeat_eq(i,j,k) for(i=(j),i<=(k);i++)
#define rev_rep(i,j,k) for(i=(j)-1;i>=k;i--)
#define all(v) (v).begin(),(v).end()

const int INF=1<<30;//=10E10

int main()
{
  while(true){
      int n;cin>>n;
      if(n==0)break;
      vector<int> v;
      rep(i,n){
	int t;cin>>t;
	v.push_back(t);
      }
      sort(all(v));
      int ans=0;
      for(int i=1;i<v.size()-1;i++)
	ans+=v[i];
      cout<<ans/(v.size()-2)<<endl;
  }
  return 0;
}

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

using namespace std;

int main(){
  int n;
  vector<int> s;

  cin>>n;
  while(n!=0){
    s.resize(n);

    for(int i=0;i<n;i++){
      cin>>s[i];
    }
    sort(s.begin(),s.end());
    s.erase(s.begin());
    s.erase(s.end()-1);

    int ans = 0;

    for(int i=0;i<n-2;i++){
      ans += s[i];
    }

    cout<<ans/(n-2)<<endl;

    cin>>n;
  }
  return 0;
}

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

#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define ALL( a )        (a).begin(), (a).end()             

int main() {
	int n;

	while( 1 ) {
		cin >> n;
		if( n == 0 ) break;
		vector<int> s( n );
		int sum = 0;
		REP( i, n ) {
			cin >> s[i];
			sum += s[i];
		}
		sort( ALL( s ) );
		sum -= s[0];
		sum -= s[n - 1];

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

}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<string>
#include<cmath>
typedef long long int ll;
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(i) i.begin(),i.end()

using namespace std;

int main(){
	int n;
	while(1){
		cin>>n;
		if(n==0)break;
		vector<int> p;
		rep(i,n){
			int tmp;
			cin>>tmp;
			p.push_back(tmp);
		}
		sort(all(p));
		ll sum=0;
		for(int i=1;i<n-1;i++){
			sum+=p[i];
		}
		cout<<sum/(n-2)<<endl;
	}
	return 0;
}