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 <bits/stdc++.h>
using namespace std;
#define N_PRIME 1000000007
#define ll int64_t


int main(void){
    
    while(true){
        int n;
        int max_v = INT_MIN;
        int min_v = INT_MAX;
        int sum = 0;
        cin >> n;
        
        if( n == 0 )return 0;
        
        for(int i = 0 ; i < n ; i++ ){
            int temp;
            cin >> temp;
            sum += temp;
            max_v = max(max_v,temp);
            min_v = min(min_v,temp);
        }
        
        sum -= max_v;
        sum -= min_v;
        
        cout << sum / (n-2) << endl;
    }
    
    return 0;
}

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

C++: import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int sum=0,i,max=0,min=1000,ave;
			int n=sc.nextInt();
			if(n==0){
				break;
			}
			for(i=0;i<n;i++){
				int point=sc.nextInt();
				if(point<min){
					min=point;
				}
				if(point>max){
					max=point;
				}
				sum=sum+point;
			}
			ave=(sum-max-min)/(n-2);
			System.out.println(ave);
		}
	}
}

C++: #include <cstdio>

using namespace std;

int main(){
  int min,max,sum,n,score;

  while(1){
    scanf=0("%d",&n);
    if(!n) break;

    max=0;min=10000;sum=0;

    for(int i=0;i<n;i++){
        scanf("%d",&score);
        if(max<score) max=score;
        if(min>score) min=score;
        sum+=score;
    }

    printf("%d",(score-max-min)/(n-2));

    return 0;
}

C++: #include<iostream>

using namespace std;

int main(){

	int n;
	int inp;
	int sum,max,min;

	while(1){

		cin>>n;
		if(n==0) break;

		cin>>inp;
		min=inp,max=inp,sum=inp;
		for(int i=1;i<n;i++){
			cin>>inp;
			sum+=inp;
			if(min>inp) min=inp;
			if(max<inp) max=inp;
		}
		cout<<(sum-min-max)/(n-2)<<endl;
	}

	return 0;
}

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

int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		int ans=0;
		int mini=1001;
		int maxi=0;
		for(int i = 0;i<n;i++){
			int a;
			cin>>a;
			ans+=a;
			mini=min(mini,a);
			maxi=max(maxi,a);
		}
		cout<<(ans-maxi-mini)/(n-2)<<endl;
	}
	return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	while(true){
		int n; cin>>n;
		if(n==0)break;
		vector<int>s(n); for(auto&&i:s)cin>>i;
		sort(s.begin(),s.end());
		cout<<accumulate(s.begin()+1,s.end()-1,0)/(n-2)<<"\n"s;
	}
}

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

int main(){
	int n;
	while(cin >>n){
		if(n == 0) break;
		vector<int> vec;
		int tmp, max, min;
		cin >>tmp;
		vec.push_back(tmp);
		max = tmp;
		min = tmp;
		bool maxb = true, minb = true;
		for(int i = 1; i < n; i++){
			cin >>tmp;
			vec.push_back(tmp);
			if(tmp > max) max = tmp;
			if(tmp < min) min = tmp;
		}
		int sum = 0;
		for(int i = 0; i < vec.size(); i++){
			if(vec[i] == max && maxb){
				maxb = false;
			} else if(vec[i] == min && minb){
				minb =false;
			} else{
				vec[i] += sum;
			}
		}
		cout <<(sum / (n - 2)) <<endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

int main() {
	int c[20];   // int[] c = new int[20];
	int w = 0;
	while (true)
	{
		int a;
		cin >>  a;// int a = int.Parse(Console.ReadLine());
		if (a == 0)
			break;
		int sum = 0;
		int b[a];
		for (int j = 0; j < a; j++)
		{
			cin >> b[j];
			sum += b[j];
		}
		int maxi = 0,mini = 1000000000;
		for (int j = 0; j < a; j++) {
			if (maxi < b[j])
				maxi = b[j];
			if (mini > b[j])
				mini = b[j];
		}
		sum -= maxi + mini;
		c[w] = (sum / (a - 2));
		w++;
	}
	for (int j = 0; j<w; j++)
	{
		cout << c[j] << endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <cctype>
#include <cstdio>
#include <iomanip>
#include <functional>
#include <stack>
#include <numeric>
#define PI 3.1415926535
#define FOR(i,n) for (int i=0; i<(n) ;i++)
#define INF 114514810

using namespace std;

int n, t, sum;
vector<int> s;

int main(){
	while (cin >> n){
		if (n == 0) break;
		FOR(i, n) {
			cin >> t;
			s.push_back(t);
		}
			sort(s.begin(), s.end());
		sum = accumulate(s.begin() + 1, s.end() - 1, 0);
		cout << sum / (n - 2) << endl;
		s.clear();
	}
}

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

C++: #include<cstdio>
#include<iostream>
#define S 100

int main(void)
{
	int a[S];
	int i;
	int n,max,min,sum=0;
	
	for(;;)
	{
		max=0, min=1000,sum=0;
		
		scanf("%d",&n);
		if(n==0) break;
		
		for(i=0; i<n; i++)
		{
			scanf("%d",&a[i]);
		}
		
		for(i=0; i<n; i++)
		{
			if(max<a[i]) max=a[i];
			if(min>a[i]) min=a[i];
		}
		
		for(i=0; i<n; i++)
		{
			sum+=a[i];
		}
		
		sum=sum-max-min;
		printf("%d\n",sum/(n-2));
	}
	
	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n, p[100], i, s;
	while (cin >> n && n)
	{
		for (i = 0; i < n; i++)
			cin >> p[i];
		sort(p, p+n);
		for (i = 1, s = 0; i < n-1; i++)
			s += p[i];
		cout << s / (n-2) << endl;
	}
}

C++: #include <algorithm>
#include <cstdio>
#include <numeric>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;

int main() {
    while (true) {
        int n; scanf("%d", &n);
        if (n == 0) break;
        vector<int> a(n); repeat (i, n) scanf("%d", &a[i]);
        whole(sort, a);
        int result = (whole(accumulate, a, 0) - a.front() - a.back()) / (n - 2);
        printf("%d\n", result);
    }
    return 0;
}