Go: package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	for n != 0 {
		arr := make([]int, n)
		for i := range arr {
			fmt.Scan(&arr[i])
		}
		sort.Ints(arr)

		sum := 0
		for i := 1; i < len(arr)-1; i++ {
			sum += arr[i]
		}
		fmt.Println(sum / (n - 2))
		fmt.Scan(&n)
	}
}

C++: #!/usr/bin/ruby
# -*- coding: utf-8 -*-

while true do
    # ????°??????§???????????? (?????????0??\???1000??\???)
    max = -1
    min = 1001
    # ????¨?????????????
    sum = 0
    # n??????
    n = gets.to_i
    break if n == 0 # 0?????¨????????????
    # n?????????????????????
    n.times do
        v = gets.to_i
        min = v if v < min
        max = v if v > max
        sum += v
    end
    sum -= (min + max)
    p sum / (n-2)
end

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

int n, sum, l, s;

int main() {
  
  while(cin>>n,n) {
    cin>>a;
    sum = a;
    l = a;
    s = a;
    for(int i=1;i<n;i++) {
      cin>>a;
      if(a>l)l=a;
      else if(a<s)s=a;
      sum+=a;
    }
    sum = sum/(n-2);
    cout<<sum<<endl;
  }
  
  return 0;
}

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

C++: #include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <map>
#include <vector>
#include <string>
#include <vector>
#include <cassert>
#include <cmath>
#include <stack>
#include <cctype>
#include <queue>
#include <algorithm>
#include <memory>
#include <memory.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int INF = 1 << 30;
const double EPS = 1e-10;
const double PI = 3.14159;

int A[200];

int main(){
	int n;
	while(cin >> n && n){
		for(int i = 0; i < n; i++){
			cin >> A[i];
		}
		int m = *max_element(A, A + n);
		int mi = *min_element(A, A + n);
		int res = accumulate(A, A + n, 0);
		cout << (res - m - mi) / (n - 2) << endl;
	}
	return 0;
}

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

using namespace std;

int main(){
	vector<int> array;
	vector<int> ans;
	int i,x,max,min,sum,n;
	max = 0;
	min = 1000;

	while(1){
	cin>>n;
	if(n==1){
		for(i=0;i<sizeof(ans);i++){
			cout<<ans[i]<< endl;
		}

		break;
	}
	array.clear();
	sum=0;

	for(i=0;i<n;i++){
		cin >> x;
		array.push_back(x);
	}
	for(i=0;i<n;i++){
		if(max<array[i]){
			max= array[i];
		}
	}
	for(i=0;i<n;i++){
		if(min>array[i]){
			min= array[i];
		}
	}
	for(i=0;i<n;i++){
		sum += array[i];
	}
	sum = sum-max-min;
	ans.push_back(sum/(n-2));  //2ひいた分だけ割る数を減らす 
	}

}

C++: #include <iostream>
#include <boost/foreach.hpp>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
    int n, tmp;
    int ans = 0;
    while(cin >> n && n) {
        vector<int> in;
        for(int i=0; i<n; ++i) {
            cin >> tmp;
            in.push_back(tmp);
        }
        sort(in.begin(), in.end());
        for(int i=1; i<n-1; ++i) ans += in[i];
        cout << ans/(n-2) << endl;
    }
}

C++: #include<stdio.h>

int main(void)
{
	int  a,b=100000,c=-1,d,i,e=0;
	while(1){
	b=100000;c=-1;e=0;
	scanf("%d",&a);
	if(a==0)
		break;
	for(i=1; i<=a; i++){
		scanf("%d",&d);
		if(c<d)
			c=d;
		if(b>d)
			b=d;
		e+=d;
	}
	
	printf("%d\n",(e-b-c)/(a-2)); 
	}
	
	return 0;
}

C++: #include <iostream>

using namespace std;

int n, s;
int main(){
    while(cin >> n && n>0){
        int sum = 0, max=0, min=10000;
        for (int i = 0; i<n; i++){
            cin >> s;
            if (s > max){
                sum += max;
                max=s;
            }
            else{
                if (s < min){
                    if(min != 10000){
                        sum += min;
                        min=s;
                    }
                    else{
                        min=s;
                    }
                }
                else{
                    sum += s;
                }
            }
        }
        cout << sum/(n-2) << endl;
    }
}

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

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

C++: #include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
int main(void){
    int n,ans=0;
    while(cin>>n,n){
        vi s(n);
        rep(i,n) cin>>s[i];
        sort(all(s));
        cout<<floor(accumulate(s.begin()+1,s.end()-1,0)/(n-2))<<endl;
    }
}

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

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

using namespace std;

int main(){
    int n, tmp;
    int ans = 0;
    while(cin >> n && n) {
        vector<int> in;
        for(int i=0; i<n; ++i) {
            cin >> tmp;
            in.push_back(tmp);
        }
        sort(in.begin(), in.end());
        for(int i=1; i<n-1; ++i) ans += in[i];
        cout << ans/(n-2) << endl;
    }
    return 0;
}

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

int main() {
	int n;
	while(cin >> n && n){
		int ans = 0, s[10000];
		for(int i = 0; i < n; ++i)
			cin >> s[i];
		sort(s, s + n);
		for(int i = 1; i < n - 1; ++i)
			ans += s[i];
		cout << ans / (n - 2) << endl;
	}
	return 0;
}

C++: #include<utility>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<deque>
#include<stack>
#include<complex>
#include<cmath>
#include<iostream>
#include<set>
#include<map>
#include<sstream>
#include<fstream>
#include<climits>
#include<chrono>
#include<random>
#include<functional>
#include<regex>

using namespace std;
typedef pair<int, int> P;
typedef long long ll;

// ??§????????°INF
const int INF = (1 << 30);
// ?¨±?????????????????
const double EPS = (1e-10);
// 2??????????????????????????????????????????
#define EQ(a,b) (abs((a)-(b)) < EPS)


int main()
{
	int n;
	while (true) {
		cin >> n;
		if (n == 0)break;
		int p = 0;
		int j;
		for (int i = 0; i < n; ++i) {
			cin >> j;
			p += j;
		}
		cout << p << endl;
	}
}

C++: #include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
#define ll long long
#define pb push_back

int main()
{
    int n,j=0;
    vector<int> x(20);

    while (1)
    {
        cin >> n;
        if (n == 0)
        {
            break;
        }
        int score;
        int sum = 0, max = 0, min = 1000;
        for (int i = 0;i<n;i++)
        {
            cin >> score;
            if(max <  score){
                max = score;
            }
            if(min > score){
                min = score;
            }
            sum += score;
        }
        sum = sum - max - min;
        // cout << sum <<  " max:" << max << " min:" << min << endl;
        x[j] = sum/(n-2);
        j++; 
    }
    for(int i=0;i<j;i++){
        cout << x[i] << endl;
    }
}