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>
using namespace std;

int main()
{
    int a,b[100];
    cin>>a;
    int max=0,min=100,sum=0,result;
    for(int i=0;i<a;i++){
        cin>>b[i];
        sum+=b[i];
        if(b[i]<min){
            min=b[i];
        }
        else if(b[i]>max){
            max=b[i];
        }
    }
    result=sum-min-max;
    cout<<result;
    return 0;
}

C++: 
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include<map>
#include<type_traits>

long long int D[10000];
long long int E[400000];

using namespace std;
int main() {
	long long int N;
	long long int Y = -1;
	cin >> N;
	while (N) {
		Y++;
		for (long long int i = 0; i < N; i++) {
			cin >> D[i];
		}

		sort(D, D + N);
		long long int W = 0;
		for (long long int i = 1; i < N-1; i++) {
			W += D[i];
		}
		E[Y] = W / (N-2);
		cin >> N;
		
	}

	for (long long int i = 0; i <=Y ;i++) {
		cout << E[i] << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;


int mean(vector<int> v) {
    int size = v.size();
    int sum = 0;
    for (int i = 0; i < size; i++){
        sum += v[i];
    }
    return sum / size;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  int ave;
  std::vector<int> v;
  while(cin >> n,n){
    for(int i=0;i<n;i++){
      int a;
      cin >> a;
      v.push_back(a);
    }
    sort(v.begin(),v.end());
    v.pop_back();
    v.erase(v.begin());
    ave = mean(v);
    cout << ave << endl;
    v.clear();
  }
}

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
int main(){
int n, sum = 0;
vector<int> point;

cin >> n;

while(n != 0){
    REP(i, n){
        int tmp;
        cin >> tmp;
        point.pb(tmp);
      }
      sort(point.begin(), point.end());

      FOR(i,1, (n-1)) sum += point[i];
      cout << (sum / (n - 2)) << endl;
      point.clear();
      sum = 0;
      cin >> n;
  }
  return 0;
}

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


int main() {
  int n;

  while (cin >> n, n) {
    int m = 1001;  
    int M = -1;
    int sum = 0;
    for (int i = 0; i < n; i++) {
      int score;
      cin >> score;
      m = min(m, score);
      M = max(M, score);
      sum += score;
    }
    cout << (sum - m - M) / (n - 2) << endl;
  }
  return 0;
}

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

using namespace std;

int main()
{
	int n;
	int s[101];
	int sum;
	
	while(scanf("%d", &n), n != 0){
		sum = 0;
		for (int i = 0; i < n;i++) scanf("%d", &s[i]);
		
		sort(s, s + n);
		
		for (int i = 1; i < n-1; i++){
			sum += s[i];
		}
		
		printf("%d\n", sum/(n-2));
	}
}

C++: #include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i, j) FOR(i, 0, j)
#define FOR(i, j, k) for(int i = j; i < k; ++i)

using namespace std;

int main(){
  int n;
  while(scanf("%d", &n) && n){
    int lmin = 9999, lmax = 0, sum = 0, s;
    rep(i, n){
      scanf("%d", &s);
      lmin = min(lmin, s); lmax = max(lmax, s);
      sum += s;
    }

    printf("%d\n", (sum - lmin - lmax) / (n-2));
  }
  return 0;
}

C++: #include <stdio.h>

int main(){

  int i,n,sum=0,min=1000,max=0,ave=0,x,l;
  int score[101];

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

      scanf("%d",&score[i]);

      if(max<score[i]){
	max=score[i];
	x=i;
      }

      if(min>score[i]){
	min=score[i];
	l=i;
      }
    }


    score[l]=0;
    score[x]=0;


    for(i=1;i<=n;i++){
      sum+=score[i];
    }
    ave=sum/(n-2);

    printf("%d\n",ave);

    ave=0;
    sum=0;
    min=1000;
    max=0;

  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <sstream>
#include <algorithm>

using namespace std;


int main () {
	while (true) {
		int n;
		cin >> n;
		if (n == 0) break;
		vector<int> v;
		int count = 0;

		for(int i = 0; i < n; i++){
			int a;
			cin >> a;
			count+=a;
			v.push_back(a);
		}
		sort(v.begin(),v.end());
		count-=v[0];
		count-=v[v.size()-1];
		cout << count/(n-2) << endl;
	}
	
	return 0;
}

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

int main(void){
  
   

   
   


}

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

int main(void){
    int n, i, tmp, sum_, max_, min_;
    while(true){
        scanf("%d", &n);
        if(n == 0) break;
        min_ = 1001;
        max_ = -1;
        sum_ = 0;
        for(i = 0; i < n; i++){
            scanf("%d", &tmp);
            sum_ += tmp;
            min_ = min(min_, tmp);
            max_ = max(max_, tmp);
        }
        sum_ = sum_ - max_ - min_;
        printf("%d\n", sum_/(n-2));
   }
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>


int main(void)
{
	int n, s[1000],i,max=0,min=1000,sum=0,lastsum;

	while (1){
		max = 0;
		min = 1000;
		sum = 0;

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

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;

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

		int s, M, m, sum = 0;
		for (int i = 0; i < n; i++) {
			cin >> s;
			if (!i) {
				M = m = s;
			}
			else if (i == 1) {
				M = max(s, M);
				m = min(s, m);
			}
			else if (s > M) {
				sum += M;
				M = s;
			}
			else if (s < m) {
				sum += m;
				m = s;
			}
			else {
				sum += s;
			}
		}
		cout << sum / (n - 2) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <climits>

using namespace std;

int main(){
    int n;
    int res[20];
    int numres = 0;
    while(1){
        cin >> n;
        if(n==0){
            break;
        }
        
        int max = INT_MIN;
        int min = INT_MAX;
        int total = 0;
        int read;
        for(int i=0; i<n; i++){
            cin >> read;
            total += read;
            if(read < min){
                min = read;
            }
            if(read > max){
                max = read;
            }
        }
        res[numres] = (total - max - min)/(n-2);
        numres++;
    }

    for(int i=0; i< numres; i++){
        cout << res[i] << endl;
    }

    return 0;
}