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<algorithm>
#include<iostream>
#define rep(i,a) for(int i=0;i<(a);++i)

int n;

int main()
{
	while( std::cin >> n, n )
	{
		int ma = 0, mi = 1001, S = 0;
	
		rep( i, n )
		{
			int a;
			std::cin >> a;
			ma = std::max( ma, a );
			mi = std::min( mi, a );
			S += a;		
		}
		
		std::cout << (S-ma-mi)/n << std::endl;
	}

	return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <fstream>
#include <stdint.h>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;

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


int main()
{
    ios::sync_with_stdio(false);
    int n;
    while(cin >> n)
    {
        if(n == 0)
            return 0;
        vector<int> nums;
        REP(i, n)
        {
            int tmp;
            cin >> tmp;
            nums.push_back(tmp);
        }
        sort(nums.begin(),nums.end());
        int sum = 0;
        RFOR(i, n-1, 1)
            sum += nums[i];
        cout << sum / (n-2) << '\n';
    }
}

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

using namespace std;

int main(){
	int			n;
	int			s_buf;
	int			sum;
	vector<int>	s;

	while(cin >> n){
		if(n == 0){
			break;
		}

		sum = 0;
		s_buf = 0;
		s.clear();

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

			s.push_back(s_buf);
		}

		sort( s.begin(), s.end() );

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

		cout << sum / (s.size() - 2) << endl;
	}
}

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

int main(void){

  int n;
  int s[1000];
  int max,min,sum,ave;

  while(1){

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

    cin >> n;

    if( n == 0 ) break;

    for( int i = 0 ; i < n ; i++ ){

      cin >> s[i];

    }

    for( int i = 0 ; i < n ; i++ ){

      if( max < s[i] ) max = s[i];

      if( min > s[i] ) min = s[i];

      sum+= s[i];

    }

    sum = sum - max - min;
    ave = sum / (n-2);

    cout << ave << endl;

  }

  return 0;

}

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

C++: #include<iostream>
using namespace std;
int main(){
while(true){
int n;
cin >> n;
if(n == 0)return 0;
int a[n];
for(int i = 0; i < n; i++)
cin >> a[i];

int max = 0;
int min = 1000;
int sum = 0;

for(int i = 0 ; i <= n ; i++){
	if(a[i] > max)
	max = a[i];
	if (a[i] < min)
	min = a[i];
	sum += a[i];
}
cout << (sum-max-min)/(n-2);

}
}

C++: #include <stdio.h>
#include <string.h>

int main(void){
	int i, j, point[1001], n, s, sum, cnt;
	scanf("%d",&n);
	while(n != 0){
		memset(point,0,sizeof(point));
		for(i = 0;i < n;i++){
			scanf("%d",&s);
			point[s]++;
		}
		for(i = 0;i <= 1000;i++){
			if(point[i]){
				point[i]--;
				break;
			}
		}
		for(i = 1000;i >= 0;i--){
			if(point[i]){
				point[i]--;
				break;
			}
		}
		sum = 0;
		cnt = 0;
		for(i = 0;i <= 1000;i++){
			for(j = 0;j < point[i];j++){
				sum += i;
				cnt++;
			}
		}
		printf("%d\n",sum / cnt);
		scanf("%d",&n);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int judge;
int maxscore;
int minscore;
int maxnum;
int minnum;
cin >> judge;
int score[judge];
	for(int i=0; i<judge; i++){
	cin >> score[i];
		if(score[i] > maxscore){
		maxscore = score[i];
		i=maxnum;
		}
		if(score[i] < minscore){
		minscore = score[i];
		i = minnum;
		}
	}
score[maxnum] = 0;
score[minnum] = 0;
int lastscore = 0;
for(int j=0;j<judge;j++){
lastscore += score[j];
}
lastscore = lastscore/(judge - 2);
cout << lastscore <<endl;
return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    int n=1,t;
    while(cin>>n,n){
        int num=0,count=0;
        vector<int> v;
        for(int i=0;i<n;i++){
            cin >>t;
            count++;
            v.push_back(t);
            num+=t;
        }
        num -= *max_element(v.begin(),v.end());
        num -= *min_element(v.begin(),v.end());
        int ans=(double)num/(count-2);
        cout<<ans<<endl; 
    }
}

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

int main() {
	int n, max, min, s;
	long sum;

	while (true) {
		cin >> n;
		sum = max = min = 0;
		if (n == 0)	break;

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

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

int main() {
  for (int j = 0;j < 20; j++ ){
    int n; cin >> n;
    if (n == 0) {
      break;
    }
    int s[n]; for (int i = 0; i < n; i++) cin >> s[i];

    sort(s, s+n);int t = 0;
    for (int i = 1; i < n - 1; i++) {
      t += s[i]; 
    }
    cout << t / (n - 2) << endl;
  }
   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;
      }
      if (smallest > S) {
	smallest = S;
      }
      sum += S;
    }
    cout << (sum-smallest-largest)/(N-2) << endl;
  }
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
const int INF = 1e9;

int main() {
    while (1) {
        int N;
        cin >> N;
        if(N==0)
            break;
        int mi = INF, ma = 0, ans = 0;
        rep(i, N) {
            int in;
            cin >> in;
            ans += in;
            mi = min(mi, in);
            ma = max(ma, in);
        }
        cout << (ans - mi - ma) / (N - 2) << "\n";
    }

    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
    int n,i;
		cout << "test";
    while(cin >> n,n){
		int p;
        int min = 1000;
        int max = 0;
		int total = 0;
		for(int i=0;i<n;i++){
			cin >> p;
			if(p > max) max = p;
			if(p < min) min = p;
			total += p;
        }
        cout << (total-max-min)/(n-2) << "\n";
    }
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
  int n;
  int point[20], average;
  
  while(1){
    average = 0;
    cin >> n;
    if(n == 0) break;

    for(int i = 0 ; i < n ; i++){
      cin >> point[i];
    }
    sort(point, point + n);
      for(int i = 1 ; i < n - 1 ; i++){
	average += point[i];
    }
    average /= (n-2);
    cout << average << endl;
  }
  return 0;
}

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

using namespace std;

int main() {
  int n, input;

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

    vector<int> scores;
    for (int i = 0; i < n; i++) {
      cin >> input;
      scores.push_back(input);
    }

    cout << (accumulate(scores.begin(), scores.end(), 0) - *max_element(scores.begin(), scores.end()) - *min_element(scores.begin(), scores.end())) / (n - 2) << endl;
  }

  return 0;
}

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

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