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())
		if n == 0 {
			break
		}
		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 < len(scores)-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

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

int score(vector<int> v) {
	int len, sum;
	sort(v.begin(), v.end());
	len = v.size();
	sum = accumulate(v.begin(), v.end(), 0);
    cout << sum / len << endl;
}

int main() {
	int n;
	vector<int> v;

	while (1) {
		cin >> n;
		if (n == 0) break;
		int tmp;
		for (int i = 0; i < n; i++) {
			cin >> tmp;
			v.push_back(tmp);
		}
        score(v);
	}

	return 0;
}

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

int main(){
	int n;
	while(n!=0){
		cin>>n;
		if(n==0){
			break;
		}
		vector<int> score;
		int hoge;
		for(int i=0;i<n;i++){
			cin>>hoge;
			score.push_back(hoge);
		}
		sort(score.begin(), score.end());
		int sum=0;
		for(int i=1;i<n-1;i++){
			sum += score[i];
		}
		cout<<sum/(n-2)<<endl;
	}
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>

using namespace std;

int matrix[20][20];

int main()
{
    while(true)
    {
        int n;

        cin >> n;
        
        if(!n) break;

        vector<int> vec(n);

        for(int i = 0; i < n; i++)
        {
            cin >> vec[i];
        }
        
        sort(vec.begin(), vec.end());

        int sum = 0;
        for(int i = 1; i < n - 1; i++){
            sum += vec[i];
        }
        cout << int(sum / (n - 2)) << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main( ){
  while(1){
    int n,a,sum=0,max=0,min=1001;
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n;i++){
      cin>>a;
      sum+=a;
      if(a>max)max=a;
      if(a<min)min=a;
    }
    cout<<(sum-max-min)/(n-2)<<endl;
  }
  return 0;
}

C++: #include<stdio.h>

int main(){
  int i, n, s;
  int ans = 0, maxv = 0, minv = 1000;

  while (1) {
    scanf("%d", &n);
    if (n==0) {
      break;
    }
    int score[n];
    for (i = 0; i < n; i++) {
      scanf("%d", &s);
      if (s > maxv) {
        maxv = s;
      }
      if (s < minv) {
        minv = s;
      }
      score[i] = s;
    }

    for (i = 0; i < n; i++) {
      ans += score[i];
    }

    printf("%d\n", (ans-maxv-minv)/(n-2));
  }
  return 0;
}

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

int main() {
	int a;
	int n;
	while(true){
		int sum=0;
		int minimum=1000,maximum=0;
		cin >> n;
		if(n==0) break;
		for(int i=0;i<n;i++){
			cin >> a;
			sum+=a;
			maximum=max(maximum,a);
			minimum=min(minimum,a);
		}
		cout << (sum-maximum-minimum)/(n-2) << endl;
	}	
	return 0;
}

C++: #include <iostream>
using namespace std;
int larger(int x,int y) {
	int z = 0;
	if (x > y)z = x;
	else z = y;
	return z;
}
int smaller(int x, int y) {
	int z = 0;
	if (x < y)z = x;
	else z = y;
	return z;
}
int main(void) {
	int s = 1;
	while (s == 1) {
		int sinsa, a[100], sum = 0, ave;
		cin >> sinsa;
		if (sinsa == 0)s = 2;
		for (int i = 0; i < sinsa; i++) {
			cin >> a[i];
		}
		int n = a[0];
		for (int i = 0; i < sinsa; i++) {
			n = larger(n, a[i]);
		}
		int m = a[0];
		for (int i = 0; i < sinsa; i++) {
			m = smaller(m, a[i]);
		}
		for (int i = 0; i < sinsa; i++) {
			sum += a[i];
		}
		sum = sum - n - m;
		ave = sum / (sinsa - 2);
		cout << ave;
	}

	return 0;

}

C++: #include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<cassert>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl

using namespace std;


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

	}


	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<climits>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define PII pair<int,int>
#define PCC pair<char,char>
#define PCI pair<char,int>
#define PIC pair<int,char>
#define MP make_pair
#define DEBUG(x) cout<<#x<<": "<<x<<endl;

int main()
{
	int n;
	for (; cin >> n, n != 0;)
	{
		int Min = INF;
		int Max = -1;
		int sum = 0;
		REP(i, n)
		{
			int temp;
			cin >> temp;
			Min = min(Min, temp);
			Max = max(Max, temp);
			sum += temp;
		}
		sum =sum - Min - Max;
		int ans = sum / (n-2);
		cout <<ans<< endl;
	}
	return 0;
}

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

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

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

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

        int s[n];
        for(int i=0;i<n;i++){
            cin>>s[i];
        }

        int max=0,min=1000;;

        for(int i=0;i<n;i++){
            if(s[i]>max)max=s[i];
            else if(s[i]<min)min=s[i];
        }
        
        int sum=0;
        for(int i=0;i<n;i++){
            sum +=s [i];
        }


        sum -=max;
        sum -=min;

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

    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n,m;
	int a,b,c;
	int i,j,k;
	int s=0;
	while(cin>>n){
		if(!n)break;
		b=0,c=1e5,s=0;
		for(i=0;i<n;i++){
			cin>>a;
			if(b<a)b=a;
			if(a<c)c=a;
			s+=a;
		}
		s-=b+c,n-=2;
		s/=n;
		cout<<s<<endl;
	}
}

C++: #include<iostream>
//#include<fstream>

using namespace std;

const int calc(int*, int);


int main(){
//	ifstream fin("in.txt");

	int data[20] = {};
	int count = 0;
	while (true){
		cin >> count;
		if (count == 0)break;
		for (int i = 0; i < count; i++){
			cin >> data[i];
		}

		for (int i = 1; i < count; i++){
			for (int j = i; j > 0; j--){
				if (data[j - 1] > data[j]){
					int tmp = data[j];
					data[j] = data[j - 1];
					data[j - 1] = tmp;
				}
			}
		}
		cout << calc(data, count) << endl;
	}

	return 0;
}

const int calc(int* a, int count){
	if (count <= 0)return 0;

	int ave = 0;

	for (int i = 1; i < count - 1; i++)ave += a[i];
	return ave / (count - 2);
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n;
  while(scanf("%d",&n),n){
    vector<int> v(n);
    for(int i=0;i<n;i++){
      int tmp;
      scanf("%d",&tmp);
      v[i]=tmp;
    }
    double ans=0;
    sort(v.begin(),v.end());
    for(int i=1;i<v.size()-1;i++){
      ans+=(double)v[i];
    }
    printf("%d\n",(int)(ans/(v.size()-2)));
  }
  return 0;
}

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

int main(void)
{
    int sum, n, mmin, mmax, in;
    while(1) {
        sum = 0; mmax = -1; mmin = 114514810;
        cin >> n;
        if(n == 0) break;
        for(int i=0; i<n; i++) {
            cin >> in;
            sum += in;
            mmax = max(mmax, in);
            mmin = min(mmin, in);
        }
        sum = sum - mmax - mmin;
        cout << sum / n << endl;
    }
    
    return 0;
}