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 <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
static const int INF = 1e+9+7;
ll n,m,l;
string s,t;
int d[200010],dp[1010][1010];
double w[1000],v[1000];
double box[200010];

int main(){
  while(1){
    cin >> n;
    if(!n)break;
    rep(i,0,n)cin >> d[i];
    sort(d,d+n);
    l = 0;
    rep(i,1,n-1)l += d[i];
    print(l / (n-2));
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007;




int main(){
	int n;
	vi v;
	while(cin>>n){
		if(n==0)break;
		v.clear();
		rep(i,n){
			int a;
			cin>>a;
			v.pb(a);
		}
		sort(all(v));
		int sum=0;
		repc(i,1,n-1){
			sum+=v[i];
		}
		//cout<<sum<<" "<<n-2<<endl;
		cout<<(int)sum/(n-2)<<endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    while(cin>>n){
        if(n==0)return 0;
        vector<int> v(n,0);
        for(int &e:v){
            cin>>e;
        }
        sort(v.begin(),v.end());
        cout<<accumulate(v.begin()+1,v.end()-1,0)/(n-2)<<endl;
    }
    return 0;
}

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

const int MAX_N = 100;

int main() {
	int n,x;
	int score[MAX_N];

	while(cin >> n) {
		if(n == 0) return 0;

		int max = -1,max_i,min = 1001,min_i;
		for(int i = 0;i < n;i++) {
			cin >> x;
			score[i] = x;

			if(max < x) {
				max = x;
				max_i = i;
			}

			if(min > x) {
				min = x;
				min_i = i;
			}
		}

		//??¨??????????????°
		if(max_i == min_i) {
			cout << max << endl;
			continue;
		}

		int total = 0;
		for(int i = 0;i < n;i++) {
			if(i != max_i && i != min_i) total += score[i];
		}

		cout << total / (n - 2) << endl;
	}
}

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

int main() {
    int n;
    while (cin>>n,n) {
        vector<ll> a(n);
        rep(i,n) cin>>a[i];
        sort(a.begin(),a.end());
        a.pop_back();
        sort(a.begin(),a.end(),greater<>());
        a.pop_back();
        ll sum = 0;
        rep(i,n-2) sum+=a[i];
        ll ans=sum/(n-2);
        cout<<ans<<endl;
    }
}

C++: 
#include <iostream>

// using namespace std;

int main()
{
    while (true)
    {
        int x;
        std::cin >> x;
        if (x == 0)
        {
            break;
        }
        long sum = 0;
        long max = 0;
        long min = 1000;
        for (int i = 0; i < x; i++)
        {
            long j;
            std::cin >> j;
            max = std::max(max, j);
            min = std::min(min, j);
            sum += j;
        }
        sum -= (min + max);
        std::cout << sum / (x - 2) << std::endl;
    }
}

C++: #include <iostream>
#include <numeric>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
#define ll long long
#define bl bool
#define nn printf("\n");
#define mod 1000000007

using namespace std;

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

	while (1)
	{
		int num = 0; cin >> num;
		if (num == 0) { break; }
		vector<int> scr(num, 0);
		rep(i, num){ cin >> scr[i]; }
		int ans = 0;
		ans = accumulate(all(scr), 0) - *max_element(all(scr)) - *min_element(all(scr));
		printf("%d\n", ans / (num - 2));
	}

	return 0;
}

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

int n,s;

int main(){
	int i;
	while( cin >> n ){
		if( !n )break;
		
		int ans = 0,mx = 0,mn = 10000;
		for( i = 0; i < n; i++ ){
			cin >> s;
			ans += s;
			mx = max( mx, s );
			mn = min( mn, s );
		}
		ans -= mx+mn;
		cout << ans/(n-2) << endl;
	}
	return 0;
}

C++: #include <stdio.h>
#include <climits>
#include <iostream>
using namespace std;
int main(){
  int n,work;
  while(1){
    int sum = 0,max=0,min=INT_MAX;
    cin >> n;
    if(n==0) break;
    for(int i=0;i<n;i++){
      cin >> work;
      max = (max < work) ? work : max;
      min = (min > work) ? work : min;
      sum+=work;
    }
    sum -=max;
    sum -=min;
    printf("%d\n",sum/(n-2));
  }

  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

int n,score[111],ave;

void solve(){
  ave = 0;
  cin>>n;

  if(n == 0) exit(0);

  REP(i,n){
    cin>>score[i];
  }

  sort(score,score+n);

  FOR(i,1,n-1){
    ave += score[i];
  }
  ave /= (n-2);

  cout<<ave<<endl;
}


int main(){

  while(1){
    solve();
  }

  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) v.begin(), v.end()
template<class T> using V = vector<T>;

int main(){
  int n;
  while(cin>>n,n){
    V<int> a(n);
    REP(i,n) cin >> a[i];
    sort(ALL(a));
    int ans = accumulate(a.begin()+1,a.end()-1,0);
    cout << ans/(n-2) << endl;
  }
}

C++: #include "bits/stdc++.h"
using namespace std;
int main() {
	int n;
	while (cin >> n,n) {
		int Sum = 0;
		int Max = -1;
		int Min = 1001;
		for (int i = 0; i < n; i++) {
			int a; cin >> a;
			Sum += a; Max = max(Max, a); Min = min(Min, a);
		}
		Sum -= Max + Min;
		cout << Sum / (n - 2) << endl;
	}
}

C++: #include <iostream>
#include <utility>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

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

const int INF = 1 << 28;

int main()
{
  int n;
  while(cin >> n, n) {
    int ax = 0;
    int in = INF;
    int sum = 0;
    rep(i, n) {
      int m;
      cin >> m;
      ax = max(ax, m);
      in = min(in, m);
      sum += m;
    }
    sum -= ax;
    sum -= in;
    sum /= n - 2;

    cout << sum << endl;
  }
  return 0;
}

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

int main()
{
    int n,s;
    int sum = 0;
    std::vector<int> v;
    cin >> n;

    for(int i = 0; i < n; i++)
    {
        cin >> s;
        v.push_back(s);
    }

    sort(v.begin(),v.end());

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