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, s, adv,  a[100];
	while(true){
		cin >> n;
		if(n == 0){
			break;
		}
	const int MAXN = 100;
	int a[MAXN];

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


	return 0;
}

C++: #include<cstdio>
#include<iostream>
using namespace std;
/*
int i_max(int data[],int size){
	int m=d[0];
	for(int i=1;i<size;i++) if(m<d[i]) m=d[i];
	return m;
}
int i_min(){
	int m=d[0];
	for(int i=1;i<size;i++) if(m>d[i]) m=d[i];
	return m;
}*/

int i_max(int p,int q){
	if(p>q) return p;
	return q;
}
int i_min(int p,int q){
	if(p<q) return p;
	return q;
}

int main(){
	int data;
	int max,min;
	int p,n;
	while(cin>>n){
		if(n==0) break;
		data=0;
		max=0;
		min=10000;
		for(int i=0;i<n;i++){
			cin>>p;
			data+=p;
			max=i_max(max,p);
			min=i_min(min,p);
		}
		data-=(max+min);
		data/=(n-2);
		cout<<data<<endl;
	}
	return 0;
}

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

int main(){
  int flag = 1;
  int n,x;
  cin >> n;
  while(flag){
    int max = -1;
    int min = 1001;
    int sum = 0;
    for(int i=0;i<n;i++){
      cin >> x;
      if(x > max){
        sum += max;
        max = x;
      }else if(x < min){
        sum += min;
        min = x;
      }else sum += x;
    }
    sum -= 1000;
    sum = sum / (n - 2);
    cout << sum << endl;
    cin >> n;
    if(n == 0) flag = 0;
  }
}

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

using namespace std;




int main(){
	while(1){
		int n;
		scanf("%d",&n);
		if(n == 0) break;
		int ma,mi,sum = 0,point;
		for(int i = 0;i < n;i++){
			scanf("%d",&point);
			sum += point;
			if(i == 0){
				ma = point;
				mi = point;
			}
			ma = max(ma,point);
			mi = min(mi,point);
		}
		printf("%d\n",(sum-ma-mi)/(n-2));
		
	}
}

C++: #include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    for(;;){
        scanf("%d",&n);
        if(n==0) break;
        vector<int> ar(n);
        for(int &x : ar){
            scanf("%d",&x);
        }
        sort(ar.begin(),ar.end());
        int sum=0;
        for(int i=1;i<n-1;i++){
            sum+=ar[i];
        }
        printf("%d\n",sum/(n-2));
    }
}

C++: #include <iostream>

using namespace std;

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

C++: #include<iostream>
using namespace std;
int main(){
int judge;
int maxscore =0;
int minscore =0;
int totalscore = 0;
cin >> judge;
if(judge != 0){
	int score;	
	for(int i=0; i<judge; i++){
	cin >> score;
		if(score > maxscore){
		maxscore = score;
		}
		if(score < minscore){
		minscore = score;
		}
		if(i==0){
		minscore = score;
		}
	totalscore += score;
	}

int lastscore = (totalscore - maxscore - minscore)/(judge - 2);
cout << lastscore <<endl;
}
return 0;
}

C++: #include <iostream>
#include <string>
#include<vector>
#include<string.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<cstdio>
using namespace std;

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

C++: #include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#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, a, b) for(int i=a; i<b; i++)
#define rFOR(i, a, b) for(int i=b-1; i>=a; i--)
#define MAX 20
using namespace std;

int main(void){
  while(true){
    int n;  cin >> n;
    if(n==0)  break;
    int s[MAX], sum=0;
    rep(i, n) cin >> s[i];
    sort(s, s+n);
    FOR(i, 1, n-1)  sum += s[i];
    cout << sum/(n-2) << endl;

  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main( void )
{
  while( 1 ){
    int n, a;
    cin >> n;
    if( n == 0 ) break;
    int minv = 1001;
    int maxv = -1;
    int s = 0;
    for( int i=0; i<n; i++ ){
      cin >> a;
      s += a;
      minv = min( minv, a );
      maxv = max( maxv, a );
    }
    cout << (s - minv - maxv) / (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 p[100];

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

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

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

      s += p[i];

    }

    cout << (s - mi - ma) / (n-2);

  }

  return 0;

}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using vll = vector<ll>;
using vvll = vector<vll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
using plli = pair<ll, int>;
using vplli = vector<pair<ll, int>>;
using pllll = pair<ll, ll>;
using vpllll = vector<pair<ll, ll>>;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i - 1; i >= (ll)end_i; i--)

long long INF = 1LL << 60;
int main()
{
    while (true)
    {
        int n;
        cin >> n;
        if (n == 0)
            break;
        ll res = 0;
        int max = -(1 << 30), min = 1 << 30;
        rep(i, 0, n)
        {
            int s;
            cin >> s;
            res += s;
            chmax(max, s);
            chmin(min, s);
        }
        cout << (res - max - min) / (n - 2) << endl;
    }
    return 0;
}