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 <bits/stdc++.h>
using namespace std;

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

typedef pair<int, int> P;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
  int N, sum;
  while( cin >> N, N ){
    sum = 0;

    vector<int> j( N );
    REP( i, N ) cin >> j[i];
    sort( ALL( j ) );
    FOR( i, 1, N - 1 ) sum += j[i];

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

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)

int main()
{
    int n, p;
    while(cin >> n && n)
    {
        vector<int> points;
        int ans = 0;

        REP(n)
        {
            cin >> p;
            points.push_back(p);
        }

        sort(points.begin(), points.end());
        
        for(int i= 1; i < n -1;i++) ans += points[i];

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

    return 0;
}

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

int N;
int S;

int main(){
  while( cin >> N ){
    if( !N ) break;
    int nmax = -1000;
    int nmin  = 2000;
    int sum = 0;
    for(int i=0;i<N;i++){
      cin >> S;
      nmax = max( nmax, S );
      nmin = min( nmin,S );
      sum += S;
    }
    sum -= nmax + nmin;
    cout << sum/(N-2) << endl;
  }
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

int main() {
    std::vector<int> vec;
    while (true) {
        vec.clear();

        int n;
        std::cin >> n;

        if (n == 0)
            break;
        
        vec.resize(n);
        for (auto&& e : vec)
            std::cin >> e;
        
        std::sort(vec.begin(), vec.end());
        std::cout << std::accumulate(vec.begin() + 1, vec.end() - 1, 0) / (n - 2) << std::endl;
    }
}

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

int main() {
  for(int tci = 0; ; ++tci) {
    int n; scanf("%d", &n);
    if(n==0) break;
    int m0v=0, m1v=1000, sum=0;
    for(int i = 0; i < n; ++i) {
      int x; scanf("%d", &x);
      sum += x;
      m0v = max(m0v, x);
      m1v = min(m1v, x);
    }
    printf("%d\n", (sum-m0v-m1v)/(n-2));
  }
  return 0;
}

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

using namespace std;

int main(){
  int N;;
  while(1){
    cin >> N;
    if(N == 0){
      break;
    }else{
      int array[N], ave, sum = 0;
      
      for(int i = 0;i < N;i++){
	cin >>array[i];
      }
      sort(array,array+N);
      for(int i = 0;i < N;i++){
	if(!(i == 0 || i == N-1)){
	sum += array[i];
	}
      }
      ave = sum /( N -2);
      cout << ave << endl;
      
    }
  }
  
  return 0;
}

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

using namespace std;

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

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

int main()
{
  int n, s, count, max, min, sum, adv;
  while(cin >> n){
    if(n == 0){
      break;
    }
    min = 1001;
    max = -1;
    sum = 0;
    count = 0;
    while(count < n){ 
      count++;
      cin >> s;
      sum += s;
      if(s < min){
        min = s;
      }
      if(s > max){
        max = s;
      }
    }
    sum = sum - max - min;
    adv = sum / (n - 2);
    cout << adv << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

struct CONTEST_DATA{
	int judgements;
	vector< int > points;
};

int main( void ){

	vector< CONTEST_DATA > contests;
	vector< int > answers;

	while( true ){
		CONTEST_DATA cd;
		cin >> cd.judgements;
		if( cd.judgements == 0 ){
			break;
		}
		int point;
		for( int i = 0; i < cd.judgements; i++ ){
			cin >> point;
			cd.points.push_back( point );
		}
		contests.push_back( cd );
	}

	for( int i = 0; i < contests.size(); ++i ){
		sort( contests[ i ].points.begin(), contests[ i ].points.end() );
	}
	for( int i = 0; i < contests.size(); ++i ){
		auto p = contests[i].points.begin();
		contests[ i ].points.erase( p );
		p = contests[ i ].points.end() - 1;
		contests[ i ].points.erase( p );
	}

	for( int i = 0; i < contests.size(); ++i ){
		int answer = 0;
		for( int l = 0; l < contests[ i ].points.size(); ++l ){
			answer += contests[ i ].points[ l ];
		}
		cout << answer / ( contests[ i ].judgements - 2 )<< endl;
	}

	return 0;
}

C++: #include <iostream>

int main() {
	while (true) {
		int referee;
		std::cin >> referee;
		if (referee == 0) {
			break;
		}

		int max, min;
		std::cin >> max >> min;
		if (max < min) {
			std::swap(min, max);
		}
		int total = 0;
		for (int i = 2; i < referee; ++i) {
			int score;
			std::cin >> score;
			if (max < score) {
				total += max;
				max = score;
			} else if (min > score) {
				total += min;
				min = score;
			} else {
				total += score;
			}
		}
		std::cout << (total / (referee - 2)) << std::endl;
	}
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main() {
	vector<int>a;
	int n, k, t;
	int x, y, z;
	int s, ans;
	bool v = true;
	ans = 0;
	while(true) {
		a.clear();
		scanf("%d", &n);
      if(n==0)return 0;
		f(i, n) {
			scanf("%d", &x);
			a.push_back(x);
		}
		sort(a.begin(), a.end());
      s=0;
		f(i, n-2) {
			s += a[i + 1];
		}
		ans = s / (n - 2);
		printf("%d\n", ans);
	}



	return 0;
}

C++: import java.util.Scanner;
public class Main{
	public static void main(String[]args){
		Scanner sc=new Scanner(System.in);
		for(int i=0;i>-1;i++){
			int num=sc.nextInt();
			if(num==0){
				break;
			}else{
			int ave=0;
			int max=0;
			int min=1000;
			int sum=0;
				int[] score =new int[num];
				//Input scores
				for(int j=0;j<num;j++){
					score[j]=sc.nextInt();
					if(score[j]>max){
						max=score[j];
					}else if(score[j]<min){
						min=score[j];
					}
					sum+=score[j];
					ave=(sum-max-min)/(num-2);
				}

					System.out.println(ave);
				}
		}
	}
}

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

int main()
{
  int n;
  int kazu=0,sum=0;
  int max,min;

  while(1)
    {
      cin >> n;

      if(n == 0)break;

      sum = 0;

      for(int i = 0;i < n;i++)
	{
	  cin >> kazu;
	  sum += kazu;

	  if(i == 0)
	    {
	      max = kazu;
	      min = kazu;
	    }

	  if(max < kazu) max = kazu;

	  if(kazu < min) min = kazu;
	}
      sum = sum - max - min;

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