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())
		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 < n-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

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

using namespace std;

int main(){
	for(int n;scanf("%d",&n),n;){
		int sum=0,mx=-1,mn=1001;
		for(int i=0;i<n;i++){
			int a;	scanf("%d",&a);
			sum+=a;
			mx=max(mx,a);
			mn=min(mn,a);
		}
		printf("%d\n",(sum-mx-mn)/(n-2));
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int n;
long int ans;
int main() {
  for(;;) {
    scanf("%d", &n);
    if(n == 0) break;
    vector<int> v(n);
    for(int i = 0; i < n; ++i) scanf("%d", &v[i]);
    sort(begin(v), end(v));
    v[n - 1] = 0, v[0] = 0;
    for(int i = 0; i < n; ++i) ans+=v[i];
    ans /= n - 2;
    printf("%ld\n", ans);
    n = 0, ans = 0;
    v.clear();
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    vector<int>in(n);
    for(int i=0;i<n;i++)cin>>in[i];
    sort(in.begin(),in.end());
    int sum=0;
    for(int i=1;i<n-1;i++)sum+=in[i];
    cout<<sum/(n-2)<<endl;
  }
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<n;++i)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define rrep(i,n) for(int i=n-1;0<=i;--i)
#define rRep(i,n) for(int i=n;0<i;--i)
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define scani(a) scanf("%d",&a)
#define scanr(a) scanf("%lf",&a)
#define scans(s) scanf("%s",s)
#define printi(a) printf("%d",a)
#define printr(a) printf("%lf",a)
#define prints(s) printf("%s",s)
#define is_odd(n) (n&1)
#define is_even(n) ((n+1)&1)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
#define all(x) x.begin(), x.end()
#define EPS 1e-8
#define INF 1e8
#define PI acos(-1.0)

typedef double Real;
typedef int Int;
typedef vector<Int> vi;
typedef vector<vector<Int> > vvi;
typedef pair<Int,Int> pii;

inline Real sr(Real a) {return sqrt(max(a, (Real)0));}
template <typename T> inline T sq(T a) {return a * a;}
const vi dy = {-1, 0, 1, 0}, dx = {0, -1, 0, 1};
vector<string> split(const string &s, char d) {vector<string> r;stringstream t(s);string x;while(getline(t,x,d))if(!x.empty())r.push_back(x);return r;}


void solve()
{
  for(;;)
  {
    Int N; scani(N);
    if(N == 0) break;

    vi s;
    s.resize(N);
    rep(i, N) scani(s[i]);

    sort(all(s));

    cout << accumulate(s.begin()+1, s.end()-1, 0) / (s.size()-2) << endl;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(9);

  solve();

  return 0;
}

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

int main() {
    int n;
    while (cin >> n, n) {
        vector<int> s(n);
        for (int i = 0; i < n; ++i) cin >> s[i];
        sort(s.begin(), s.end());

        int sum = 0;
        for (int i=1; i<n-1; ++i) {
            sum += s[i];
        }
        cout << sum / (n - 2) << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
	while( 1 ){
		int sum = 0;
		int n, s;
		deque< int > scores;
		scanf( "%d", &n );
		if( !n ){ return 0; }
		for( int i = 0; i < n; i++ ){
			scanf( "%d", &s );
			scores.push_back( s );
		}
		sort( scores.begin(), scores.end() );
		for(deque<int>::iterator it = scores.begin() + 1; it + 1 != scores.end(); it++){
			sum += *it;
		}
		
		printf( "%d\n", sum / ( n - 2 ) );
	}
}

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

int main()
{
    int n, a[100];

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

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

C++: # include <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;


int main() {
  int n;

  while (cin >> n) {
    if (!n) break;

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

    int  sum = 0;
    int _max = scr[0];
    int _min = scr[0];

    for (int s : scr) {
      sum  += s;
      _min = min(_min, s);
      _max = max(_max, s);
    }

    sum -= _max;
    sum -= _min;

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

  return 0;
}

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

#define pb         push_back

const int INF = 100000000;

int main(void) {
	while(1){
		int n;
		vector<int> vec;
		cin >> n;
		if(n == 0) break;

		for(int i=0; i<n; i++){
			int t;
			cin >> t;
			vec.pb(t);
		}
		sort(vec.begin(), vec.end());

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

		cout << ans << endl;
	}

	
	return 0;
}

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

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

using namespace std;

int main(){
  int n;
  while(cin>>n,n!=0){
    vector<int> score(n);
    rep(i,n)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>

using namespace std;

int main(){
	int N;
	const int NMAX = 100;
	int score[NMAX];

	while (1) {
		cin >> N;
		if (N==0) break;
		
		int max, min;
		int sum = 0;
		for (int i=0; i<N; ++i) {
			cin >> score[i];
			sum += score[i];
			if (i == 0) {
				max = min = score[0];
			} else {
				if ( score[i] > max ) max = score[i];
				if ( score[i] < min ) min = score[i];
			}
		}
		cout << (sum-max-min)/(N-2) << endl;

	}

	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>
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)return 0;
		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 <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n1;
	cin >> n1;
	int a[100000] = { 0 };
	for (int i = 0; i < n1; i++){
		cin >> a[i];
	}
	sort(a, a + n1);
	a[0] = { 0 };
	a[n1 - 1] = { 0 };
	for (int i2 = 1; i2 < n1; i2++){
		a[0] += a[i2];
	}
cout << a[0] / (n1 - 2) << endl;
	return 0;
}