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++: #include<iostream>

using namespace std;

int main(){
  int n,i,p,max,min,s;

    while(1){
      cin>> n;
      if(n){}else break;
      
      cin>> p;
      s = p;
      max = p;
      min = p;

      for(i = 0 ; i < n-1 ;i++){
          cin>> p;
          s += p;
          if(max < p){
              max = p;
	  }
          if(min > p){
              min = p;
	  }
      }
      s = (s - max - min)/ (n-2);
      cout<< p << 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<iostream>

using namespace std;

int main () {

  while (true){

    int n;
    int i;
    int s = 0;
    int mi = 0;
    int ma = 0;
    cin >> n;

    if (n == 0)
      break;
??????
??????int point[100];

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

      if (point[i] < mi)
        mi << point[i];

      if (point[i] > ma)
        ma << point[i];

      s += point[i];
    }

    cout << (s - mi - ma) / (n-2) << endl
  }
  return 0;
}

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

using namespace std;

struct CONTEST_DATA{
	int judgements;
	vector< int > points;
};

int main( void ){

	vector< CONTEST_DATA > contests;
	vector< int > answers;

	while( true ){
		CONTEST_DATA cd;
		cin >> cd.judgements;
		if( cd.judgements == 0 ){
			break;
		}
		int point;
		for( int i = 0; i < cd.judgements; i++ ){
			cin >> point;
			cd.points.push_back( point );
		}
		contests.push_back( cd );
	}

	for( int i = 0; i < contests.size(); ++i ){
		sort( contests[ i ].points.begin(), contests[ i ].points.end() );
	}
	for( int i = 0; i < contests.size(); ++i ){
		vector< int >::iterator p = contests[i].points.begin();
		contests[ i ].points.erase( p );
		p = contests[ i ].points.end() - 1;
		contests[ i ].points.erase( p );
	}

	for( int i = 0; i < contests.size(); ++i ){
		int answer = 0;
		for( int l = 0; l < contests[ i ].points.size(); ++l ){
			answer += contests[ i ].points[ l ];
		}
		cout << answer / ( contests[ i ].judgements - 2 )<< endl;
	}

	return 0;
}

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

int main(){
    int N;
    vector<int> ans;

    while(cin>>N,N!=0){
        vector<int> point(N);
        for(int &i : point) cin>>i;

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

        int ave = 0;

        for(int i = 1; i < N-1;i++) ave += point[i];

        ans.push_back(ave/(N-2));
    }

    for(int i:ans) cout<<i<<endl;

}

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

int main() {
    int num, score, sum, max, min, i;
    while(1){
        cin >> num;
        if(!num)
            break;
        sum=0;
        max=0;
        min=10000;
        for(i=0; i<num; i++){
            cin >> score;
            if(score>max)max=score;
            if(score<min)min=score;
            sum+=score;
        }
        sum-=max;
        sum-=min;
        cout << sum/(num-2) << endl;
    }
    return 0;
}

C++: #include<iostream>

int mein() {

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

int main(){
    register int n,i;
    while(cin >> n,n){
		register int p;
        register int min = 1000;
        register int max = 0;
		register 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<bits/stdc++.h>
using namespace std;

// macro
using ll = long long;

// code starts
int main()
{
  int n;
  cin >> n;
  while(n != 0)
  {
    vector<int> s(n);
    for(int i=0;i<n;i++) cin >> s[i];
    sort(s.begin(), s.end());
    int sum = 0;
    for(int i=1;i<n-1;i++) sum += s[i];
    cout << sum/(n-2) << endl;
    cin >> n;
  }
}

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;
}

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

C++: /*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp*/

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;

    while (cin>>n && n>0){
        vector<int> s;

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

            cin>>tmp;
            s.push_back(tmp);
        }
        sort(s.begin(),s.end());
        cout<<accumulate(++s.begin(),--s.end(),0)/(n-2)<<endl;
    }
    return 0;
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	while(n != 0){
		int max, min;
		int ans,t;
		ans = 0;
		max = 0; min = 1000;
		for(int i = 0; i < n; i++){
			cin >> t;
			if(t > max) max = t;
			if(t < min) min = t;
			ans += t;
		}
		ans -= (max + min);
		ans /= n - 2;
		cout << ans << endl;
		cin >> n;
	}
	
	return 0;
}

C++: #include <iostream>
#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 <iostream>
using namespace std;
int main(){
	int n,i,t,a;
	while(cin>>n,n){
		t=0;
		for(i=0;i<n;i++)cin>>a,t+=a;
		cout<<t/n<<endl;
	}
}

C++: #include <iostream>
using namespace std;
int N, S;

int main(){
  while( cin >> N && N > 0){ //N??????????????????????????????????????§while????????????
    int sum = 0; 
    int min = 0;
    int max = 0;
    //int average = 0;

    for (int i = 0; i < N; cin >> S){
      sum += S;
      if( S > max ) max = S;
      else if(S < min) min = S; 
    }

    sum -= min + max;
    sum /= N - 2;

    //average = sum - min - max / N - 2; //???N-2?????§???????????¨?????¨??????

    cout << sum << endl;
  }

  return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<map>
#include<vector>
using namespace std;
int prime[300000];
int main() {
	int n;
	while(cin >> n,n) {
		int ans = 0;
		vector<int> data;
		for(int i = 0; i < n; i++) {
			int t;
			cin >> t;
			data.push_back(t);
			ans += t;
		}
		sort(data.begin(), data.end());
		ans = ans - data[data.size()-1] - data[0];
		cout << ans / (n - 2) << endl;
	}
	return 0;
}