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>
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);
		}
	}
}

C++: #include <stdio.h>
int main(){
  int n,s,i,min=1000,max=3,sum=0,ave;
  while(1){
    scanf("%d",&n);
    if(n==0){
      break;
    }
    for(i=0;i<n;i++){
      scanf("%d",&s);
      if(s<min){
    min=s;
      } 
      if(s>max){
    max=s;
      }
      sum=sum+s;
    }
    sum=sum-max-min;
    ave=sum/(n-2);
    printf("%d\n",ave);
    sum=0;
    min=1000;
    max=3;
  }
  return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

//typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;
const int INF = 1000000000;

int main(){

	int n,s;
	while(cin >> n && !(n == 0)){
		int maxNum = 0;
		vector<int> nums;
		for(int i = 0; i < n; i++){
			int x;
			cin >> x;
			nums.push_back(x);
		}
		sort(nums.begin(),nums.end());
		int sum = 0;
		for(int i = 1; i < nums.size() - 1; i++){
			sum += nums[i];
		}
		cout << (int)((double)sum/(nums.size()-2)) << endl;
	}

	return 0;
}

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

int N, S;
int main() {
    while(cin >> N && N > 0) {
        int sum = 0;
        int maxi=0, mini=1000000;
        for (int i=0; i<N; ++i) {
            cin >> S;
            sum += S;
            if (S > maxi) {
                maxi = S;
            }
            if (S < mini) {
                mini = S;
            }
        }
        double ans = (sum - maxi - mini) / (N - 2);
        cout << ans << endl;
    }
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for (int i=(n)-1;i>=0;i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define REPS(i,f,n) for (int i=(f)-1;i>=(n);i--)
int dx[4] = {1, 0, 0, -1};
int dy[4] = {0, 1, -1, 0};

void slove(int s){
	int ma = s;
	int mi = s;

	ll sum = s;
	int tmp;
	cin >> tmp;
	while(tmp != 0){
		sum += tmp;
		ma = max(tmp, ma);
		mi = min(tmp, mi);
		cin >> tmp;
	}
	
	printf("%lld\n", sum - ma - mi);
	return;
}

int main(void){

	int s;
	rep(i, 110){
		scanf("%d", &s);
		slove(s);
	}

	return 0;
}