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 reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

vector<int> x;

void init(){
  x.clear();
}
bool input(){
  int n;
  cin>>n;
  if(n==0)return false; 
 rep(i,n){
    int a;
    cin>>a;
    x.push_back(a);
  }
  return true;
}

int solve(){
  sort(x.begin(),x.end());
  int sum = 0;
  reps(i,1,x.size()-1)sum+=x[i];
  return sum/(x.size()-2);
}
int main(){
  while(init(),input()){
    printf("%d\n",solve());
  }
}

C++: #include<bits/stdc++.h>
using namespace std;
const int INF = (1<<30);

int main()
{
  int n;
  while( cin >> n, n ) {
    int ma = 0, mi = INF, sum = 0, data;

    for(int i=0; i<n; i++) {
      cin >> data;
      sum += data;
      if( data > ma ) ma = data;
      if( data < mi ) mi = data;
    }
    
    sum = sum - ma - mi;
    cout << sum / (n-2) << endl;
  }

}

C++: #include <iostream>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int main()
{
	int n;
	while(cin >> n,n){
		int s[100];

		for(int i = 0; i < n; i++)
			cin >> s[i];

		sort(s,s+n);

		int sum = 0;
		for(int i = 1; i < n-1; i++)
			sum += s[i];

		cout << sum / (n-2) << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int p;
  int s[1000];
  int sum=0;
  while(1){
    cin>>p;
    if(p==0) break;
    for(int i=0;i<p;i++){
      cin>>s[i];
      sum+=s[i];
    }
    sort(s,s+p);
    for(int j=0;j<p;j++){
      /* cout<<s[j]<<endl;*/
    }
    cout<<sum-s[0]-s[p-1]<<endl;
  }
  return 0;
}

C++: #include<stdio.h>

void sort(int p[],int n);

void sort(int p[],int n)
{
    int i,j,temp;

    for (i = 0; i < n - 1; i++) {
        for (j = n - 1; j > i; j--) {
            if (p[j-1] > p[j]) {
                temp = p[j];
                p[j] = p[j-1];
                p[j-1] = temp;
            }
        }	
    }
}

int main(void)
{
	int i;
	int j;
	int k;
	int n;
	int d[20];
	int p[100];
	int sum;
	int ave;
	
	j=0;
	while(1){


		scanf("%d",&n);
		if(n==0) 
			break;
			
		for(i=0;i<n;i++){
		scanf("%d",&p[i]);
		}

		sort(p,n);	
	
		sum = 0;
		for(i=1;i<n-1;i++){
			sum += p[i];
		}
			
			d[j] = sum / (n-2);
			j++;

	}
	
	for(k=0;k<j;k++)
		printf("%d\n",d[k]);

	return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define REEP(i, N) for(ll i = N - 1; i >= 0; --i)
#define FOR(i,m,n) for(ll i = m; i < n; ++i)
#define RFOR(i,m,n) for(ll i = n - 1; i >= m; --i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define PB push_back
#define KIRIAGE(a, b) a += (b - a % b) % b // a ??? b ????????°????????§?¢???????
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;} // a / b ??\??????????°???´??°
#define sp(n) setprecision(n)
#define INF 1000000000
#define MOD 1000000007
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
int dx8[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
int main(void) {
    while(true) {
        int n;
        cin>>n;
        if(!n)return 0;
        vector<int> s(n);
        ll sum = 0;
        REP(i, n) {
            cin>>s[i];
            sum += s[i];
        }
        sort(ALL(s));
        sum -= s[0];
        sum -= s[n - 1];
        cout<<sum / (n - 2)<<endl;
    }
}

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

int main(){
  int n, s, sum, max, min;
  while(1){
    cin >> n;
    if(n == 0) break;
    sum = 0;
    max = 0;
    min = 100;
    for(int i = 0; i < n; 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<bits/stdc++.h>
using namespace std;

int main(){
  int n,s[100],num,max,min,a;
  
  while(true){
    num =0;
   
  cin>>n;
  if(n == 0)break;

  cin>>s[0];
  max=s[0];
  min=s[0];
  num=s[0];

    
  for(int i=1;i<n;i++){
    cin>>s[i];
    
    if(max<s[i])max=s[i];
    if(min>s[i])min=s[i];
       
    num += s[i];
  }
  a = (num-max-min)/(n-2);

  cout<<a<<endl;
    
  }
  return 0;
}

C++: #include <bits/stdc++.h> 

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int n;
  while(cin>>n){
    if(n==0)return 0;
    vector<int>s(n);
    for(int i=0;i<n;i++)cin>>s[i];
    sort(rng(s));
    int ans=0;
    for(int i=1;i<n-1;i++)ans+=s[i];
    cout<<ans/(n-2)<<endl;
  }
  return 0;
}

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

using namespace std;

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

C++: #include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1) {
		ll n;
		cin>>n;
		if(n==0) break;
		vector<ll> s(n);
		REP(i,n) cin>>s[i];
		sort(ALL(s));
		ll sum=accumulate(ALL(s),0);
		sum-=s[0]+s[n-1];
		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 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 - largest - smallest) / (N - 2)) << endl;
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	while(true){
		int score;
		int n;
		int maxs,mins;
		vector<int> s(n);
		cin>>n;
		if(n==0)break;
		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++: #include <iostream>

using namespace std;

int main() {
  int n, s;
  while (true) {
    cin >> n;
    if (n == 0) break;
    int m = 1001, M = -1, sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> s;
      if (s < m) m = s;
      if (s > M) M = s;
      sum += s;
    }
    sum = sum - m - M;
    cout << sum / (n - 2) << endl;
  }
  
  return 0;
}