Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for {
		num := nextInt(sc)
		if num == 0 {
			break
		}

		score_list := []int{}
		for i := 0; i < num; i++ {
			score_list = append(score_list, nextInt(sc))
		}
		// 得点リストをソートした後、最低点と最高点を取り除く(3 ≤ n ≤ 100)
		sort.Sort(sort.IntSlice(score_list))
		score_list = score_list[1 : len(score_list)-1]
		// 得点リストの得点を合計し、スライスの個数で割って平均点を出す
		sum := 0
		for _, score := range score_list {
			sum += score
		}
		fmt.Println(sum / len(score_list))
	}
}

C++: #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

#define Rep(b, e, i) for (int i = b; i <= e; i++)
#define Repr(e, b, i) for (int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n - 1, i)
#define repr(n, i) Repr(n - 1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)), (x).end())

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1 << 31 - 1;
const int MOD = 1000000007;

void solve(void) {
  while (1) {
    int N;
    scanf("%d\n", &N);
    if (N == 0)
      break;
    vector<int> ps;
    rep(N, i) {
      int p;
      scanf("%d\n", &p);
      ps.pb(p);
    }
    sort(all(ps));
    int ans = ps[0] + ps[N - 1];
    for (int t : ps) {
      if (t != ps[0] && t != ps[N-1]) ans += t;
    }
    printf("%d\n", ans / N);
  }
}

int main(void) {
  solve();
  return 0;
}

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

int main(){
	int n,sum,max,min;
	while(cin>>n&&n>0){
		int S;
		min=1000000000;
		max=0;
		sum=0;
		for(int i=0;i<n;i++){
			cin>>S;
			sum+=S;
			if(min>S){
				min=S;
			}
			if(max<S){
				max=S;
			}
		}
		sum-=(min+max);
		cout<<sum/(n-2)<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<string>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define INF 1145141919810893931
using namespace std;

int main() {
	ll n; cin >> n;
	while (n) {
		vector<ll> a(n);
		vector<ll> b(n - 2);
		rep(i, n) cin >> a[i];
		sort(a.begin(), a.end());
		ll b_count = 0;
		nrep(i, 1, n - 1) b[b_count++] = a[i];
		ll sum = 0;
		rep(i, b.size()) sum += b[i];
		cout << sum / b.size() << endl;
		cin >> n;
	}
	return 0;
}

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

int main()
{
	int x[20], y, i, j, n, sum = 0;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> x[i];
		sum += x[i];
	}
	sort(x,x+n);

	cout << (sum-x[0]-x[n-1]) / (n - 2);
	return 0;
}

C++: #include <stdio.h>
#include <float.h> 
int main(void){	
  int n[100];	
  int a[1000];	
  int i,j,max[100],min[100],suma[100],sumb[100],ave[100]; 
  for(i = 0;;i++){  
    scanf("%d",&n[i]);
    if(n[i]==0)break;  
    for(j=0 ; j<n[i] ;j++){ 
      scanf("%d",&a[j]);
    } 
    max[i] = a[0];
    min[i] = a[0];
    suma[i] = 0; 
    for(j=0 ; j<n[i] ; j++){
      if(a[j] >= max[i]){
	max[i] = a[j];
      }
      if(a[j] <= min[i]){
	min[i] = a[j];
      }
      suma[i] += a[j];
    }
  } 

  for(j = 0;j < i;j++){
    sumb[j] = suma[j]-max[j]-min[j]; 
    n[j] -= 2;
    ave[j] = sumb[j] / n[j] ;
    printf("%d\n",ave[j]);    
  }
  return 0;
  
}

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

int main()
{
	int n,m;
	int ave[1000]={0};

	m=0;
	while(1){
		int point[100]={0};
		int min=1000;
		int max=0;
		cin>>n;
		if(n==0) break;
		for(int i=0;i<n;i++){
			cin>>point[i];
			if(point[i]>max) max=point[i];
			if(point[i]<min) min=point[i];
			ave[m]++;
		}
		ave[m]=(ave[m]-max-min)/(n-2);
	m++;
	}
	for(i=0;i<m;i++){
		cout<<ave[i]<<endl;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    while(cin>>n and n){
        int a[n]={};
        int max=-5,min=10000,sum=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
            if(a[i]<min){
                min=a[i];
            }
            if(a[i]>max){
                max=a[i];
            }
            sum+=a[i];
        }
        int ave=(sum-max-min)/(n-2);
        cout<<ave<<endl;
    }
    return 0;
}

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

C++: #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
	int n,a;
	vector<int>vec;
	int sum;
	while(true){
		cin>>n;vec.clear();
		if(n==0){break;}
		for(int i=0;i<n;i++){
			cin>>a;
			vec.push_back(a);
		}
		sort(vec.begin(),vec.end());
		sum=0;
		for(int i=0;i<vec.size();i++){
			sum+=vec[i];
		}
		cout<<(sum-vec[0]-vec[vec.size()-1])/(vec.size()-2)<<endl;
	}
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int n;
	while(cin>>n,n!=0){
		vector<int> a(n);
		rep(i,n)cin>>a[i];
		cout<<(accumulate(all(a),0)-*max_element(all(a))-*min_element(all(a)))/(n-2)<<endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
        int n, s ;
	while (cin >> n && n > 0){
		int large = 0;
		int small = 1000;
		int sum = 0;
  		for (int i=0; i>n; ++i){
			cin >> s;
			sum = sum + s;
			if (large < s) {large = s};
			if (small > s) {small = s};
		};
		int ans = 0;
		ans = (sum - large - small) / (n - 2);
		cout << ans << endl ;
	};
}

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


int main()
{
	int n;
	int point[100];
	while (cin >> n)
	{
		if (n == 0)break;
		int sum = 0;
		for (int i = 0; i < n; i++)
		{
			cin >> point[i];
		}

		sort(point,point + n);

		for (int i = 1; i < n - 1; i++)
		{
			sum += point[i];
		}

		cout << sum / (n - 2) << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
#define NUMBER 20
int main(void)
{
	int j = 0;
	while (j < NUMBER){

		int h,i, n, b;
		int a[100];

		cin >> n;

		if (n == 0)
			break;

		for (i = 0; i < n; i++)
			cin >> a[i];

		for (i = 0; i < n-1; i++) {
			for (h = 1; h < n; h++) {
				if (a[i] > a[h]) {
					b = a[i];
					a[i] = a[h];
					a[h] = b;
				}
			}
		}
		
		b = 0;

		for (i = 1; i < (n - 1) ; i++)
			b = b + a[i];

		cout << (b / (n - 2)) << endl;

		j++;
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int n;
int a[100];
int M, m, s;
int main()
{
	cin >> n;
	while(n!=0)
	{	
		cin >> a[0];
		M=a[0];
		m=a[0];
		s=a[0];
		for(int i=1; i<n; i++)
		{
			cin >> a[i];
			M=max(M, a[i]);
			m=min(m, a[i]);
			s+=a[i];
		}
		cout << (s-M-m)/(n-2) << endl;
		cin >> n;
	}
	return 0;
}

C++: import java.util.Arrays;
import java.util.Scanner;
public class main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		while(true){
			int sum=0;
			int ave=0;
			int n=scan.nextInt();
			if(n==0){
				break;
			}
			int[] s = new int[n];
			for(int i = 0;i < n;i++){
				s[i]=scan.nextInt();
			}
			Arrays.sort(s);
			for(int i=1;i<n-1;i++){
				sum+=s[i];
			}
			ave=sum/(n-2);
			System.out.println(ave);
		}
	}
}