Go: package main

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

var (
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	for sc.Scan() {
		n, _ := strconv.Atoi(sc.Text())
		scores := make([]int, n, n)
		for i := 0; i < n; i++ {
			sc.Scan()
			scores[i], _ = strconv.Atoi(sc.Text())
		}
		sort.IntSlice(scores).Sort()
		var sum = 0
		for i := 1; i < n-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

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

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