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 <stdio.h>
#include <algorithm>

int main(void)
{
    while(true) {
        int M=0,m=50000,n,sum=0;
        scanf("%d", &n);
        if(n==0) break;
        for(int i=0; i < n; i++)
        {
            int s;
            scanf("%d", &s);
            M = std::max(s, M);
            m = std::min(s, m);
            sum += s;
        }
        printf("%d\n", (sum-M-m)/(n-2));
    }

    return 0;

}

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

C++: #include<iostream>
#include<algorithm>
int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int n;
	int avg=0;
	int s[100];
	while (true){
		std::cin >> n;
		if (n == 0) break;
		int q = n - 2;
		for (int i = 0; i < n; i++){
			std::cin >> s[i];
		}
		std::sort(s, s + n);
		for (int i = 1; i <= n-2; i++){
			avg += s[i];
		}
		std::cout << avg /q << "\n";
		avg = 0;
		for(int i = 0; i < n; i++){
			s[i]=0;
		}
	}
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a[101],sum,n;
	while(cin>>n,n){
	sum=0;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<n;i++)cout<<a[i]<<" ";
	for(int i=0;i<n;i++)if(i!=0&&i!=n-1)sum+=a[i];
	cout<<"sum"<<sum;
	cout<<sum/(n-2)<<endl;
	}
	return 0;
}

C++: //a
#include <iostream>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <functional>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>

#define REP(i,b,n) for(int i=b;i<n;i++)
#define REPR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PB push_back
#define MP make_pair

using namespace std;

static const double PI = acos(-1.0);
static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> pii;

int main(){
	
	int n;
	int s[1000];
	
	while(cin>>n, n){
		
		for(int i=0; i<n; ++i){
			cin>>s[i];
		}
		
		sort(s, s+n);
		
		int sum=0;
		
		for(int i=1; i<n-1; ++i){
			sum+=s[i];
		}
		
		sum /=n-2;
		
		cout << sum << endl;
	}
	
	return 0;	
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	int x[1000] = { 0 };
	int y[20] = { 0 };
	int max;
	int min;
	n = 1;
		int j = 0;
		while (n != 0){
			
			cin >> n;
			max = 0;
			min = 1000;
				y[j] = 0;
			for (int i = 0; i < n; i++){
				cin >> x[i];
				if (max < x[i]) max = x[i];
				if (min > x[i]) min = x[i];
				y[j] += x[i];
			}
			y[j] = y[j]-max - min;
			y[j] = y[j] / (n - 2);
			j++;
		}
	for (int k = 0; k < j; k++){
		cout << y[k]<< endl ;
	}
	return 0;
}

C++: #include <iostream>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <bitset>

using namespace std;

int main(void)
{
  while (true) {

    int n;
    cin >> n;
    if (n == 0) break;
    int p[n];
    for (int i = 0; i < n; i++)
      cin >> p[i];
    int top,bottom,sum;
    top = -1;
    bottom = 1001;
    sum = 0;
    for (int i = 0; i < n; i++) {
      if (top < p[i])
	top = p[i];
      if (bottom > p[i])
	bottom = p[i];
    }
    //cout << top << "  " << bottom << endl;
    
    bool t, b;
    t = b = true;
    for (int i = 0; i < n; i++) {
      if (top == p[i] && t) {
	t = false;
      }
      else if (bottom == p[i] && b) {
	b = false;
      }
      else
	sum+=p[i];
    }
    cout << (int)(sum/(n-2)) << endl;
    
  }
  return 0;	
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N;
  cin>>N;
  while(N>0){
    vector<ll> v(N);
    FOR(i,0,N){
      cin>>v[i];
    }
    sortAl(v);
    ll res=0;
    FOR(i,1,N-1){
      res+=v[i];
    }
    cout<<res/(N-2)<<endl;
    cin>>N;
  }
}

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

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

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

using namespace std;

int main() {
	int n;
	while (cin >> n, n) {
		int ma=0, mi=1000000000;
		int ans = 0;
		for (int i = 0; i < n; i++) {
			int buf; cin >> buf;
			ma = max(ma, buf);
			mi = min(mi, buf);
			ans += buf;
		}
		cout << (ans - ma - mi) / (n - 2) << endl;
	}
}

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

int main() {
  int n, tmp;
  while(cin >> n && n != 0){
    vector<int> s;
    for(int i = 0; i < n; i++) {
      cin >> tmp;
      s.push_back(tmp);
    }
    sort(s.begin(), s.end());
    s.erase(s.begin()); s.erase(s.end() - 1);
    tmp = 0;
    for(auto i: s) {
      tmp += i;
    }
    cout << tmp / (n - 2)<< endl;
  }
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  while(true) {
    int n;
    cin >> n;
    vector<int> v;
    int a;
    rep(i, n) {
      cin >> a;
      v.push_back(a);
    }
    sort(ALL(v));

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

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cctype>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <sstream>
#include <deque>

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

using namespace std;

int main() {
    int n;

    while(cin >> n, n) {
        vector<int> judge(n);
        int sum = 0;

        REP(i, n) {
            cin >> judge[i];
        }
        sort(judge.begin(), judge.end());

        REP(i, n-2) {
            // cout << judge[i+1] << endl;
            sum += judge[i+1];
        }
        cout << (sum/(n-2)) << endl;

    }

    return 0;
}