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 <iostream>
using namespace std;
int main()
{
  int n[20]={};
  int s[20][100]={};
  int answer[20]={};
  int MAX=-1,min=1001,jM=0,jm=0;
  int i=0,j=0;

  for(;;i++){
    cin >> n[i];//?????°??\???
    if(n[i]>=3&&n[i]<=100){
      for(MAX=-1,min=1001,j=0;j<n[i];j++){//?????°?¶??????????
	cin >> s[i][j];
	if(MAX<s[i][j]){//?????§????±???????
	  MAX=s[i][j];
	  jM=j;
	}
	if(min>s[i][j]){//????°??±???????
	  min=s[i][j];
	  jm=j;
	}
	answer[i]+=s[i][j];
      }
      
      answer[i]=(answer[i]-s[i][jM]-s[i][jm])/(n[i]-2);
    }else{
      break;
    }
  }
  for(i=0;n[i]>=3&&n[i]<=100;i++){//??????
    cout << answer[i] << endl;
  }
}

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

int main (){
	int n, i, max, min;
	int A[101];
	int sum;
	while (cin >> n && n > 0){
		sum = 0;
		for (i = 0; i < n; i++){
			cin >> A[i];
		}
		max = min = A[0];
		for (i = 0; i < n; i++){
			if (max < A[i]){
				max = A[i];
			}
			if (min > A[i]){
				min = A[i];
			}
			sum += A[i];
		}
		sum -= max;
		sum -= min;
		cout << sum / (n - 2) << endl;
	}

	return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int MOD=1000000007;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;


int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		int ans=0,s[110];
		rep(i,0,n)cin>>s[i];
		sort(s,s+n);
		rep(i,1,n-1)ans+=s[i];
		print(ans/(n-2));
	}
	return 0;
}

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

class foo{
public:
  int icpc(int n){
    int ma=0, mi=1000, sum=0,s;
		for(int i=0;i<n;i++){
			cin >> s;
			ma=max(ma, s);
			mi=min(mi, s);
			sum+=s;
		}
		return (sum-ma-mi)/(n-2);
  }
  
  int main(){
    int n;
	  while(true){
  		cin >> n;
		  if(!n)return 0;
		  cout << icpc(n) << endl;
	  }
    return 0;
  }
};

int main(){return (new foo)->main();}

C++: #include <iostream>

int main() {
    using namespace std;

    int c;
    int num;
    int max ;
    int min;
    int sum;
    int ans;
    while(true){
        max = 0;
        min = 1001;
        sum = 0;
        cin >> c;
        if(c == 0){
            break;
        }
        for(int i = 0; i < c; i++){
            cin >> num;
            if(num > max){
                max = num;
            }
            if(num < min){
                min = num;
            }
            sum += num;
        }
        ans = (sum - max - min)/(c-2);
        cout << ans << "\n";
    }
    return 0;
}

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

int main(){
  int n, s, sum, max, min;
  while(1){
    cin >> n;
    if(n == 0) break;
    sum = 0;
    cin >> s;
    max = s;
    cin >> s;
    if(max < s){
      max = s;
    }else{
      min = s;
    }
    for(int i = 0; i < n -2; i++){
      cin >> s;
      sum += s;
      if(max < s) max = s;
      if(min > s) min = s;
    }
    sum -= max;
    sum -= min;
    int ave = sum / (n-2);

    cout << ave << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<string>
#include<stdlib.h>

using namespace std;
#define rep(i,n) for(auto i=(n)*0;i<n;i++)
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	cout << fixed << setprecision(30);
	int n;
	while (cin >> n, n){
		int top = 0, bottom = 1000,sum=0;
		rep(i, n){
			int s;
			cin >> s;
			sum += s;
			top = max(top, s);
			bottom = min(bottom, s);
		}
		cout << sum - top - bottom << endl;
	}
	return 0;
}

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

int main()
{
  int ave[20];
  int jsup=0;
  for(int j=0;j<20;j++)
    {
      int n;
      cin >> n;
      if(n==0)
	{
	jsup = j;
	break;
	}
      int s[100];
      int max=-1, min=1001;
      int max_i = -1, min_i=-1;
      for(int i=0;i<n;i++)
	{
	  cin >> s[i];
	  if(s[i] > max)
	    {
	      max = s[i];
	      max_i = i;
	    }
	  if(s[i] < min)
	    {
	      min = s[i];
	      min_i = i;
	    }
	  if(i == n-1 && max == min)
	    min_i = max_i+1;
	}
      int sum=0;
      for(int i=0;i<n;i++)
	{
	  if(i==max_i || i==min_i)
	    continue;
	  else
	    sum += s[i];
	}
      ave[j] = sum/(n-2);
    }
  for(int j=0;j<jsup;j++)
    {
      cout << ave[j] << endl;
    }
}

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

int main(){
    int n;

    while(!cin.eof()){
        vector<int> point;
        int data;
        int ave=0;

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

    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 , temp;
        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;
                }
            }
            if (max < min){
                max = temp;
                min = max;
                max = temp;
            }
        }
        cout << sum/(n-2) << endl;
    }
}

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

int main(){
  while( cin >> N && N > 0){
    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; 
    }
    
    average = sum - min - max / N; 

    cout << average << endl;
  }

  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>
int D[1000];
int E[1000];

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

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

	for (int i = 0; i <=Y ;i++) {
		cout << E[i] << endl;
	}
	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>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>

using namespace std;
int main(){
	int n;
	while(1){
		cin >> n;
		if(n == 0) break;
		int s[n], i, sum = 0, ave = 0;
		for(i = 0;i < n;i++){
			cin >> s[i];
		}
		sort(s, s+n);
		s[0] = 0;
		s[n-1] = 0;

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

		cout << ave << endl;
	}
	return 0;
}