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++: /* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 
                                                           
*/
/* }}} */
/* include {{{ */
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
using namespace std;
/* }}} */

// #define int long long

/* cpp template {{{ */
/* short */
#define pb push_back
#define mp make_pair
#define print(x) cout << x << '\n'
#define Fi first
#define Se second

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}
inline bool inside(int y, int x, int H, int W) {return (y >= 0 && x >= 0 && y < H && x < W);}

/* }}} */

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

  for (int n; cin >> n, n;){
    vi a(n);
    REP(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    int ans = 0;
    RREP(i, a.size() - 2) ans += a[i];
    print(ans / (a.size() - 2));
  }

  return (0);
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
using namespace std;

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

int main() {
  int n;
  while(cin>>n,n) {
    vector<int> v(n);
    REP(i,n)
      cin >> v[i];
    v.erase(max_element(ALL(v)));
    v.erase(min_element(ALL(v)));
    int sum = 0;
    FOR(i,v) {
      sum+=*i;
    }
    cout << sum/v.size() << endl;
  }
}

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl;
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// Aliases
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

int main() {
    while(true) {
        int n;
        cin >> n;
        if(n == 0) break;
        int sum = 0, smn = INT_MAX, smx = INT_MIN;
        REP(i, n) {
            int s;
            cin >> s;
            sum += s;
            smn = min(smn, s);
            smx = max(smx, s);
        }
        cout << (sum - smn - smx) / (n - 2) << "\n";
    }

    return 0;
}

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

using namespace std;

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

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

   int n;

   while(cin >> n && n != 0){
      int a[n],sum = 0;
      rep(i,n){
         cin >> a[i];
      }
      sort(a,a+n);
      for(int i = 1; i < n - 1; ++i){
         sum += a[i];
      }
      cout << sum / (n - 2) << endl;
   }

   return 0;
}

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

int main ()
{
	int n, s, adv,  a[100];
	while(true){
		cin >> n;
		if(n == 0){
			break;
		}
	const int MAXN = 100;
	int a[MAXN];

	for(int i = 0 ; i < n; i++){
		cin >> a[i];
	}
	int max = a[0], min = a[0], kei = 0;
	for(int i = 0 ; i < n ; i++){
		if(max < a[i]){
			max = a[i];
		}
		if(min > a[i]){
			min = a[i];
		}
		kei += a[i];
	}
	adv = (kei - max - min) / (n - 2);
	cout << "   " << adv << endl;
	}


	return 0;
}

C++: #include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
  int n;

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

    int sum = 0;
    int min_val = 10000;
    int max_val = -1;
    for (int i = 0; i < n; i++) {
      int s;
      cin >> s;
      min_val = (min_val > s) ? s : min_val;
      max_val = (max_val < s) ? s : max_val;
      sum += s;
    }
    sum -= min_val + max_val;
    cout << (sum / (n - 2)) << endl;
  }
  return 0;
}

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

int main(){

  while(1){
    int n;
    int p[200];
    cin >> n;

    if(n == 0) break;
    int max = -1,min = 2000;
    for(int i = 0;i< n;i++){
      cin >> p[i];
      if(max < p[i])max = p[i];
      if(min > p[i])min = p[i];
    }

    int sum = 0,count=0;
    for(int i = 0;i< n;i++){
      if(max == p[i]){
	max = -1;
	continue;
      }
      if(min == p[i]){
	min = 2000;
	continue;
      }
      sum += p[i];
      count++;
    }

 
    cout << sum / count << endl;;

  }
  return 0;
}

C++: #include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
#define rep(i, n) for(int i=0; i<(n); ++i)

int main(void){
    int n, tmp;
    int ans = 0;
    while(cin >> n && n) {
        vector<int> in;
        rep(i, n) {
            cin >> tmp;
            in.push_back(tmp);
        }
        sort(in.begin(), in.end());
        ans = 0;
        for(int i=1; i<n-1; ++i) ans += in[i];
        cout << ans/(n-2) << endl;
    }
}

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


using namespace std;

int main(void){


    int n;
    int s[128];
    while(scanf("%d", &n), n){
        int maxi = 0;
        int mini = 1000000000;
        int total=0, ns=0;

        for(int i = 0; i < n; i++){
            scanf("%d", &s[i]);
            if(s[i] > maxi){
                maxi = s[i];
            }
            if(s[i] < mini){
                mini = s[i];
            }
        }

        for(int i = 0; i < n; i++){
            if(maxi == s[i]){
                maxi = -1;
                continue;
            }
            if(mini == s[i]){
                mini = -1;
                continue;
            }
            total += s[i];
            ns++;
        }
        printf("%d\n", total/ns);
    }



    return 0;
}