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>
#include <vector>
#include <algorithm>

using  namespace std;
int n;
void solve(){
  int inputMin=10001, inputMax=-1;
  int score,ans = 0;
  for(int input = 0; input < n ; input ++){
    cin >> score;
    ans += score;
    inputMin = min(inputMin , score);
    inputMax = max(inputMax , score);
  }
  ans = (ans - inputMin -inputMax)/ (n-2);
  cout << ans << endl;
}
int main(){

  while(cin >> n){
    if(n == 0) break;
    solve();
  }


  return 0;
}

C++: #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

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

int n;

void solve()
{
  vector<int> v;
  rep(i, n) {
    int s; cin >> s;
    v.push_back(s);
  }
  sort(v.begin(), v.end());

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

int main()
{
  while (cin >> n and n) {
    solve();
  }

  return 0;
}

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

int N, S;

int main()
{
   while ( cin >> N && N>0)
   {
      int M, m, addup, i;
      M = -1;
      m = 1001;
      for ( i = 0; i<N; i++)
      {
         cin >> S;
         addup += S;
         if ( S > M) M = S;
         if ( S < m) m = S;
      }
   cout << (addup - M - m)/(N-2)  << endl;
   }
}

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

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

C++: //#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <cstring>
#include <climits>
#define INF INT_MAX / 2
using namespace std;

typedef pair<double, double> P;
typedef long long ll;

int main(void) {
  int n;

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

// command ctrl 上下
// command D
// command caps G → '' ""

C++: #include <iostream>

using namespace std;

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

    int in[100];
    int sum=0;
    for(int i=0;i<n;i++){
      cin >> in[i];
      sum+=in[i];
    }

    int min=100000;
    int max=-1;
    for(int i=0;i<n;i++){
      if(min>in[i]) min=in[i];
      if(max<in[i]) max=in[i];
    }
    sum-=min;
    sum-=max;
    printf("%d\n", (int)(sum/(n-2)));
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
	int n;
	int s;
	int min = 10000;
	int max = 0;
	int sum = 0;
	vector<int> results;
	while(cin>>n){
		if(n==0){
			break;
		}
		for(int j = 0;j<n;j++){
                    cin>>s;
		    sum+=s;
		    if(s>max)
                       max = s;
                    if(s<min)
                       min = s;
		}
		sum = (sum-max-min)/(n-2);
                results.push_back(sum);
                min = 10000;
                max = 0;
                sum = 0;
	}
	int size = results.size();
	for(int i = 0;i<size;i++){
		cout<<results[i]<<endl;
	}
}

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

using namespace std;

int main(){
	int n, ave;
	int s[10000];
	while(true){
		cin >> n;
		if(n == 0){
			break;
		}
		for(int i = 0; i < n; i++){
			cin >> s[i];
		}
		sort(s, s + n);
		ave = 0;
		for(int i = 1; i < n - 1; i++){
			ave += s[i];
		}
		ave /= (n - 2);
		printf("%d\n", ave);
	}
	return 0;
}

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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {
	int result[100] = {};
	int pos = 0;
	while (1) {
		int n;
		int s[101] = {};
		int mini = 1001;
		int maxi = -1;
		int total = 0;

		cin >> n;
		if (n == 0) {
			break;
		}
		pos++;
		FOR(i, 1, n) {
			cin >> s[i];
			if (maxi < s[i]) {
				maxi = s[i];
			}
			else if (mini > s[i]) {
				mini = s[i];
			}
			total += s[i];
		}
		result[pos] = (total - maxi - mini) / (n - 2);
	}
	FOR(i, 1, pos) {
		cout << result[i] << endl;
	}

}

C++: #include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
#include <fstream>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define sz(x) ((int)(x).size())

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
const ll MOD = 1000000007;
//const ll MOD = 998244353;
double EPS = 1e-10;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.12lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

void solve(){
  while(true){
    int n;
    cin >> n;
    if(n == 0) return;
    int sum = 0;
    int Ma = -1, mi = INF;
    rep(i, n){
      int a;
      cin >> a;
      sum += a;
      Ma = max(Ma, a);
      mi = min(mi, a);
    }
    sum -= Ma + mi;
    cout << sum / (n-2) << endl;
  }
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  solve();
}

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

int main() {
    for(int n; scanf("%d", &n),n;) {
        int sum=0,miv=1000,mav=0;
        for(int i = 0; i < n; i++) {
            int s; scanf("%d", &s);
            sum+=s;
            miv=min(miv,s);
            mav=max(mav,s);
        }
        printf("%d\n", (sum-miv-mav)/(n-2));
    }
    return 0;
}

C++: #include<iostream>
#include<deque>
#include<algorithm>
#include<numeric>
using namespace std;
int main()
{
	int n,s;
	while(cin>>n,n)
	{
		deque<int>d(n);
		while(n--)cin>>s,d[n]=s;
		sort(d.begin(),d.end());
		d.pop_back(),d.pop_front();
		cout<<accumulate(d.begin(),d.end(),0)/d.size()<<endl;
	}
	return 0;
}