Go: package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	for n != 0 {
		arr := make([]int, n)
		for i := range arr {
			fmt.Scan(&arr[i])
		}
		sort.Ints(arr)

		sum := 0
		for i := 1; i < len(arr)-1; i++ {
			sum += arr[i]
		}
		fmt.Println(sum / (n - 2))
		fmt.Scan(&n)
	}
}

C++: #include <vector>
#include <algorithm>
#include <iostream>
#include <iomanip>
using namespace std;
typedef vector<int> VI;
#define PB push_back
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main(){
	while(1){
		int n;
		cin >> n;
		if(n==0)return 0;
		VI v;
		int s=0;
		REP(i,n){
			int tmp;
			cin >> tmp;
			v.PB(tmp);
		}
		SORT(v);
		FOR(i, 1, n-1)s+=v[i];
		cout << s/(n-2) << endl;
	}
}

C++: #include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<random>
#include<string>
typedef long long ll;
using namespace std;
int main(){
  ll N;
  ll s[1100];
  ll sum=0;
  ll t=0;
  while(t<=20){
  t++;
  cin >> N;
  for(ll i = 0; i < N; ++i){
      cin >> s[i];
  }
  sort(s,s+N);
  for(ll i = 1; i < N-1; ++i){
    sum+=s[i];
  }
  cout<<sum/(N-2)<<endl;
}
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
	int n;
	while(cin >> n, n) {
		vi v(n);
		rep(i, n) cin >> v[i];
		sort(all(v));
		int s = accumulate(v.begin() + 1, v.end() - 1, 0);
		cout << s / (n - 2) << endl;
	}
}

C++: #include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;

using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する

void solve(int n) {
    int min_v = 114514;
    int max_v = 0;
    int sum = 0;
    rep(i,0,n){
        int tmp;
        cin >> tmp;
        sum += tmp;
        min_v = min(tmp,min_v);
        max_v = max(tmp,max_v);
    }
    sum -= min_v + max_v;
    cout << sum / (n-2) << endl;
}

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

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


    return 0;
}

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

using namespace std;

int nums[10000];

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

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

int main(){
    int n;
    while(cin >> n){
        vector<int> judges;
        for(int i=0; i<n; i++){
            int score;
            cin >> score;
            judges.push_back(score);
        }
        sort(judges.begin(), judges.end());
        judges.erase(judges.begin());
        judges.pop_back();

        int sum = accumulate(judges.begin(), judges.end(), 0);
        int score = sum / judges.size();
        cout << score << endl;
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    while(n!=0){
        int s, sum = 0, large = 0, small = 1000;
        for(int i=0;i<n;++i){
            cin >> s;
            sum+=s;
            if(large<s) large=s;
            if(small>s) small=s;
        }

        cout<<(sum-large-small)/(n-2)<<"\n";

        cin >> n;
    }
}

C++: #include <iostream>

using namespace std;

void swap(int *a,int *b){
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

void babbleSort(int *a,int n){
	for(int i=0;i<n;i++){
		for(int j=n-1;j>i;j--){
			if(a[j]>=a[j-1]){
				swap(&a[j],&a[j-1]);
			}
		}
	}
}

int main(){

	int n;

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

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

	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<random>
#include<map>
#include<queue>
using namespace std;

int main(){

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

    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    int sum = accumulate(a.begin(), a.end(), 0) - *max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end());

    sum /= n-2;
    cout << sum << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <ctime>
#include <iterator>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int main()
{
    int n;
    while(cin>>n)
    {
        if(n==0) break;
        int sum = 0;
        int mini = 10000000;
        int maxi = 0;
        for(int c=0;c<n;c++)
        {
            int z;
            cin>>z;
            mini = min(mini,z);
            maxi = max(maxi,z);
            sum += z;
        }
        cout<<(sum-mini-maxi)/(n-2)<<endl;
    }
}