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>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  while(true){
    int n;
    scanf("%d",&n);
    if(n==0)break;
    vi a(n);
    REP(i,n)scanf("%d",&a[i]);
    sort(ALL(a));
    int sum = 0;
    FOR(i,1,n-1)sum += a[i];
    sum /= (n-2);
    printf("%d\n",sum);
  }
  return 0;
}

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

int main() {

  long N;
  std::vector<long> v;
  long temp;
  long ans;
  long total;

  for(;;) {
    v.clear();
    std::cin >> N;
    if( N == 0 ) break;

    for(int i = 0; i < N; ++i) {
      std::cin >> temp;
      v.push_back(temp);
    }

    std::sort(std::begin(v), std::end(v));

    total = 0;
    for(int i = 1; i < N-1; ++i) total += v[i];
    ans = total / (N-2);

    std::cout << ans << std::endl;
  }
  
  return 0;
}

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

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

    vector<int> p(n);
    int nmax = -1, nmin = 1001;
    int imax, imin;
    for(int i=0; i<n; i++){
      cin >> p[i];
      if(p[i] > nmax){
	nmax = p[i];
	imax = i;
      }
      if(p[i] < nmin){
	nmin = p[i];
	imin = i;
      }
    }

    int ave = 0;
    for(int i=0; i<n; i++){
      if(i != imax && i != imin)
	ave += p[i];
    }
    ave /= n-2;

    cout << ave << endl;
  }
  
  return 0;
}

C++: #include <iostream>
#include<stdio.h>
using namespace std;
int main(void){
   int n;
   int x[21];
   while(1){
       int max=-1,min=1001;
       int S=0;
       cin>>n;
       if(n==0){
           break;
       }
       for(int i=0;i<n;i++){
            cin>>x[i];
            if(min>x[i]){
                min=x[i];
            }
            if(max<x[i]){
                max=x[i];
            }
           S=S+x[i];            
       }
       cout<<(S-(max+min))/(n-2)<<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>
#define INF (2<<29)
using namespace std;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    for(;;){
        int a,n,s=0,max=0,min=INF;
        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-2)<<endl;
    }
    return 0;
}

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

using namespace std;

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
typedef complex<int> P;
typedef pair<int,int> pii;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
template <class F, class T> void convert(const F &f, T &t){	stringstream ss; ss << f; ss >> t;}


bool solve(int n){
	vector<int> a(n);
	for(int i=0;i<n;i++) cin>> a[i];
	
	sort(all(a));
	int ans = 0;
	for(int i=1;i<n-1;i++) ans += a[i];
	ans /= n-2;
	
	cout<< ans<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed); cout.precision(10);
	int n;
	while(cin>> n, n){
		solve(n);
	}
	return 0;
}

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

using namespace std;

#define MAX 100

int n, s[MAX];

int main() {
	while (1) {
		scanf("%d", &n);
		if (n == 0)
			return 0;

		for(int i = 0; i < n; i++)
			scanf("%d", s + i);
		sort(s, s + n);

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

		printf("%d\n", ans / (n - 2));
	}
}

C++: #define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	for (;;) {
		int n; 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());
		int sum = 0;
		for (int i = 1; i < n - 1; i++) sum += s[i];
		cout << sum / (n - 2) << endl;
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

using namespace std;

int solve(int );

int main(void){
  int N;

  while(1) {
    cin>>N;
    if(N==0) return 0;
    else solve(N);
  }
  return 0;
}

int solve(int N){
  vector<int> score(N);
  FOR(i,0,N){
    cin>>score[i];
  }
  sort( score.begin(),score.end() );

  int sum;
  FOR(i,1,N-1){
    sum += score[i];
  }
  int ans = sum/(N-2);
  cout<<ans<<endl;
  sum=0;
}