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++: //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 <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout(n) cout << fixed << setprecision(n)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acosl(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int n;
int s[110];


signed main(){
    while(cin >> n, n > 0){
        rep(i, 0, n) cin >> s[i];
        int a = accumulate(s, s+n, 0LL);
        a -= *max_element(s, s+n);
        a -= *min_element(s, s+n);
        cout << a/(n-2) << endl;
    }

    return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    while( n > 0){
        vector<int> v(n);
        for(int i = 0; i < n; ++i){
            cin >> v[i];
        }
        int max_ = *max_element(v.begin(), v.end());
        int min_ = *min_element(v.begin(), v.end());
        int min_cnt = 0;
        int max_cnt = 0;
        int cnt = 0;
        long long sum = 0;
        for(int j = 0; j < n; ++j){
            int s = v[j];
            if(s == max_) {
                max_cnt++;
            } else if(s == min_) {
                min_cnt++;
            } else {
                sum += s;
                cnt++;
            }
        }
        if(max_cnt > 1) {
            sum += max_;
            cnt++;
        }
        if(min_cnt > 1) {
            sum += min_;
            cnt++;
        }

        cout << (sum/cnt) << endl;
        cin >> n;
    }
}

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

int main(){
	int n;
	while(1){
		int a[100]={0};
		int sum=0;
		cin>>n;
		if(n==0) break;
		for(int i=0 ; i<n ; i++){
			cin >> a[i] ;
		}
		for(int i=n-1 ; i>=0 ; i--){
			for(int j=0 ; j< i ; j++){
				if(a[j]>a[j+1]){
					a[j]^=a[j+1];
					a[j+1]^=a[j];
					a[j]^=a[j+1];
				}
			}
		}
		for(int i=1 ; i<n-1 ; i++){
			sum+=a[i];
		}
			cout << sum/(n-2) << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int n;
	while(cin >> n && n)
	{
		vint v(n);
		rep(i, n)
			cin >> v[i];

		cout << (accumulate(ALL(v), 0) - *max_element(ALL(v)) - *min_element(ALL(v))) / (n - 2) << endl;
	}
}

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

int main(){
	int n,s,sum,min,max;
	refrain:
	cin>>n;
	if(n==0) return 0;
	min=1001;
	max=-1;
	sum=0;
	for(int i=0;i<n;i++){
		cin>>s;
		if(s>max) max=s;
		if(s<min) min=s;
		sum+=s;
	}
	sum-=max+min;
	sum/=n-2;
	cout<<sum<<endl;
	goto refrain;
}

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

using namespace std;

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

        int sum{0};
        int max_{-1};
        int min_{10000};
        for (int i = 0; i < n; ++i) {
            int s;
            cin >> s;
            sum += s;
            max_ = max(max_, s);
            min_ = min(min_, s);
        }
        cout << ((sum - max_ - min_) / (n - 2)) << endl;
    }
}

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

int main(){
    
    while(true){
        int n;
        cin >> n;
        
        if(n == 0) break;
        
        vector<int> a(n);
        int minv = 1001;
        int maxv = -1;
        int sum = 0;
        rep(i,n){
            cin >> a[i];
            minv = min(minv,a[i]);
            maxv = max(maxv,a[i]);
            sum += a[i];
        }
        sum = sum - minv - maxv;
        sum /= (n-2);
        
        cout << sum << endl;
    }
}

C++: #include <algorithm>
#include <iostream>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int m=1<<28,M=0,s=0;
    for(int i=0;i<n;++i){
      int t;cin>>t;
      m=min(m,t);
      M=max(M,t);
      s+=t;
    }
    cout << (s-m-M)/(n-2) << endl;
  }
  return 0;
}