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 <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;

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

    int n;
    while (cin >> n, n) {
        vector<int> v(n);
        rep(i, n) cin >> v[i];
        sort(all(v));
        cout << accumulate(v.begin() + 1, v.end() - 1, 0) / (n - 2) << endl;
    }
}

C++: //#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <utility>
using namespace std;
#define INF 100000005
#define MAX 200005

int a[1001];
int main(){
	int n, sum;
	while(cin >> n, n){
		sum = 0;
		for(int i = 0;i < n;i++){
			cin >> a[i];
			sum += a[i];
		}
		sum -= *max_element(a, a+n);
		sum -= *min_element(a, a+n);
		cout << sum/(n-2) << endl;
	}
	return 0;
}

C++: #include <iostream>

int main() {
	while (1) {
		int N;
		int s[100];
		std::cin >> N;
		if ( N == 0 ) break;
		for ( int i=0; i<N; i++ ) {
			std::cin >> s[i];
		}
		int min=s[0], max=s[0], sum=0;
		for ( int i=0; i<N; i++ ) {
			if ( min > s[i] ) min = s[i];
			if ( max < s[i] ) max = s[i];
			sum += s[i];
		}
		std::cout << (int)((sum-min-max)/(N-2)) << std::endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	while(true){
		int score;
		int n;
		int maxs,mins;
		cin>>n;
		if(n==0)break;
		vector<int> s(n);
		for(int i=0;i<n;i++){
			cin>>s[i];
		}
		maxs=*max_element(s.begin(),s.end());
		mins=*min_element(s.begin(),s.end());
		for(int i=0;i<n;i++){
			score+=s[i];
		}
		cout<<(score-maxs-mins)/(n-2)<<endl;
	}
}

C++: // AOJ 1147
#include<iostream>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main() {
  int n;
  while (cin >> n and n) {
    int sum = 0, mxm = -1e5, mnm = 1e5;
    REP(i, n) {
      int s;
      cin >> s;
   
      if (mxm < s) mxm = s;
      if (mnm > s) mnm = s;
   
      sum += s;
    }
   
    cout << (sum - mxm - mnm) / (n - 2) << endl;
  }
}

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

using namespace std;

int main() {
	int n;
	while (cin >> n && n != 0) {
		vector<int> s(n);
		for (int i = 0; i < n; ++i) cin >> s[i];

		sort(s.begin(), s.end());
		int ave = 0;
		for (int i = 1; i < n - 1; ++i) ave += s[i];
		ave /= (n - 2);
		cout << ave << endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<iostream>
#define S 20

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

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

using namespace std;

int main(){
	int n;

	cin >> n;

	while(n != 0){
		int point[1005];
		int max = 0, min = 0;

		for(int i=0; i<n; i++){
			cin >> point[i];
		}

		for(int i=1; i<n; i++){
			if(point[max] < point[i])
				max = i;
			else if(point[i] < point[min] )
				min = i;
		}

		point[max] = 0;
		point[min] = 0;

		int sum = 0;

		for(int i=0; i<n; i++)
			sum += point[i];

		//cout << sum << endl;

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

		cin >> n;
	}

	return 0;
}

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

int main(){
	int n;
	cin>>n;
	vector<int> d(n);
	for(int i=0;i<n;i++)
		cin>>d[i];
	for(int i=0;i<10000;i++){
		bool isok=true;
		if(i<10){
			for(int j=0;j<n;j++)
				if(d[j]==i){
					isok=false;
					break;
					
				}
			if(!isok) continue;
			cout<<i<<endl;
			return 0;

		}
		else if(i<100){
			for(int j=0;j<n-1;j++)
				if(d[j]==i/10 && d[j+1]==i%10){
					isok=false;
					break;
				}
				if(!isok) continue;
				cout<<i<<endl;
				return 0;

			}
		else if(i<1000){
			for(int j=0;j<n-2;j++)
				if(d[j]==i/100 && d[j+1]==(i/10)%10&&d[j+2]==i%10){
					isok=false;
					break;
				}
				if(!isok)	continue;
				cout<<i<<endl;
				return 0;
			}
		else
			for(int j=0;j<n-3;j++){
				if(d[j]==i/1000 &&d[j+1]==(i/100)%10 &&d[j+2]==(i/10)%10 && d[j+3]==i%10){
					isok=false;
					break;
				}
				if(!isok) continue;
				cout<<i<<endl;
				return 0;
			}


	}


}

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

using namespace std;

int main() {
	int n;
	int judge[100];
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		int sum = 0;
		for (int i = 0; i < n; i++) {
			cin >> judge[i];
		}
		for (int i = n; i > 1; i--) {
			for (int j = 0; j < i-1; j++) {
				if (judge[j] > judge[j+1]) {
					swap(judge[j], judge[j+1]);
				}
			}
		}
		for (int i = 1; i < n-1; i++) {
			sum += judge[i];
		}
		cout << sum/(n-2) << endl;
	}
	return 0;
}

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

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

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

int main(void){
	int n,m,max,min,answer;
	while(1){
		cin >> n;
		max = 0;
		min = INT_MAX;
		answer = 0;
		if (!n) break;
		for (int i=0;i< n;i++){
			cin >> m;
			if (m > max) max = m;
			else if (m < min) min = m;
			answer += m;

		}
		cout << (answer-max-min)/(n-2) << endl;

	}

	return 0;
}

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

int main() {
	int n, i, p[100], t;
	int max, min, maxi, mini;
	cin >> n;
	
	while (n != 0){
		max = 0; min = 1000; t = 0;

		for (i = 0; i < n; i++) {
			cin >> p[i];
		}

		for (i = 0; i < n; i++) {
			t += p[i];

			if (p[i] > max) {
				maxi = i;
				max = p[i];
			}

			if (p[i] < min) {
				mini = i;
				min = p[i];
			}
		}

		cout << (t - p[maxi] - p[mini]) / (n - 2) << endl;

		cin >> n;
	}
}

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

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

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

int main(){

  int n, s,  min, max;
  int total;
  while(cin >> n){
    total = 0;

   if(n == 0) break;

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

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