Go: // ICPC 得点集計ソフトウェア
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for	{
		n := nextInt(sc)
		if n == 0 { break }

		score_list := []int{}
		for i := 0; i < n; i++ {
			score_list = append(score_list, nextInt(sc))
		}

		// 最低点と最高点を取り除く (3 ≤ n ≤ 100)
		sort.Sort(sort.IntSlice(score_list))
		score_list = score_list[1:len(score_list)-1]

		// 平均点を求める
		sum := 0
		for _, score := range score_list {
			sum += score
		}
		fmt.Println(sum / len(score_list))
	}
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

C++: #include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<random>
#include<string>
typedef long long ll;
using namespace std;
int main(){
  ll N;
  ll s[1100];
  ll sum=0;
  ll t=0;
  while(t<=20){
  s++;
  cin >> N;
  for(ll i = 0; i < N; ++i;){
      cin >> s[i];
  }
  sort(s,s+N);
  for(ll i = 1; i < N-1; ++i){
    sum+=s[i];
  }
  cout<<sum/(N-2)<<endl;
}
}

C++: #include <iostream>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <bitset>
#include <tuple>

using namespace std;

int main(void)
{
  while (true) {

    int n;
    cin >> n;
    if (n == 0) break;
    int p[n];
    for (int i = 0; i < n; i++)
      cin >> p[i];
    int top,bottom,sum;
    top = -1;
    bottom = 1001;
    sum = 0;
    for (int i = 0; i < n; i++) {
      if (top < p[i])
	top = p[i];
      if (bottom > p[i])
	bottom = p[i];
    }
    //cout << top << "  " << bottom << endl;
    
    bool t, b;
    t = b = true;
    for (int i = 0; i < n; i++) {
      if (top == p[i] && t) {
	t = false;
      }
      else if (bottom == p[i] && b) {
	b = false;
      }
      else
	sum+=p[i];
    }
    cout << (int)(sum/(n-2)) << endl;
    
  }
  return 0;	
}

C++: #include<stdio.h>

void QSort(int x[ ], int left, int right);
void Swap(int x[ ], int i, int j);

void QSort(int x[ ], int left, int right)
{
    int i, j;
    int pivot;

    i = left;                   
    j = right;                  

    pivot = x[(left + right) / 2];
    while (1) {                   

        while (x[i] < pivot)      
            i++;                  

        while (pivot < x[j])      
            j--;                  
        if (i >= j)               
            break;                

        Swap(x, i, j);            
        i++;                      
        j--;
    }

    if (left < i - 1)              
        QSort(x, left, i - 1);     
    if (j + 1 <  right)            
				QSort(x, j + 1, right);    
		}

void Swap(int x[ ], int i, int j)
{
    int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}

int main(void)
{
	int i;
	int j;
	int k;
	int n;
	int d[20];
	int p[100];
	int sum;
	int ave;
	
	j=0;
	while(1){


		scanf("%d",&n);
		if(n==0) 
			break;
			
		for(i=0;i<n;i++){
		scanf("%d",&p[i]);
		}

		QSort(p,0,n-1);	
	
		sum = 0;
		for(i=1;i<n-1;i++){
			sum += p[i];
		}
			
			d[j] = sum / (n-2);
			j++;

	}
	
	for(k=0;k<j;k++)
		printf("%d\n",d[k]);

	return 0;
}

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

int main() {
  while(true){
    int a;
    cin >> a;

    if(a == 0){
      break;
    }

    vector<int> b(a);
    int max = -9999;
    int min = 99999;
    int maxi,mini;
    for(int i = 0; i < a; i++){
      cin >> b[i];
      if (max < b[i]) { max = b[i];maxi = i; }
      if (min > b[i]) { min = b[i];mini = i; }
    }
    b[mini] = 0;
    b[maxi] = 0;

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

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

int main(void){
    while(true){
        int n, min=10000, max=-1, sum=0;
        cin >> n;
        if(n==0) break;
        for(int i=0;i<n;++i){
            int s;
            cin >> s;
            sum += s;
            max = (max > s)? max: s;
            min = (min < s)? min: s;
        }
        cout << (sum-max-min)/(n-2) << endl;
    }
}

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

using namespace std;

typedef long long ll;

int main() {
  int n;
  while(cin >> n, n) {
    int max_score = 0;
    int min_score = 1000;
    int s;
    int m = 0;
    for (int i = 0; i < n; i++) {
      cin >> s;
      m += s;
      max_score = max(max_score, s);
      min_score = min(min_score, s);
    }
    cout << (m - max_score - min_score) / (n - 2) << endl;
  }
}

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

C++: #include <iostream>
using namespace std;
int N, S;
int main() {
	while (cin >> N && N > 0) {
		int sum = 0;
		int largest = 0;
		int smallest = 1000;
		for (int i = 0; i < N; ++i) {
			cin >> S;
			if (largest < S) {
				largest = S;
			} else if (smallest > S) {
				smallest = S;
			}
			sum += S;
		}
		cout << ((sum - largest - smallest) / (N - 2)) << endl;
	}
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <queue>

#pragma warning( disable: 4996 )

using namespace std;

typedef long long ll;

#define INF 100000000
#define EPS 1e-9

#define MAX_N 100

int n;
vector<int> ans_list;

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

		vector<int> score;

		for (int i = 0; i < n; i++){
			int s;
			cin >> s;
			score.push_back(s);
		}
	
		sort(score.begin(), score.end());

		int ans = 0;

		for (int i = 1; i < score.size() - 1; i++){
			ans += score[i];
		}

		ans_list.push_back(ans / (score.size() - 2));
	
	}

	for (int i = 0; i < ans_list.size(); i++){
		cout << ans_list[i] << endl;
	}

	return 0;

}