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()
{
loop:
  int min = 1 << 30, max = 0, sum = 0, n;
  cin >> n;
  if(!n)
    return 0;
  for(int i = 0; i < n; i++)
  {
    int tmp;
    cin >> tmp;
    max = max < tmp ? tmp : max;
    min = min > tmp ? tmp : min;
    sum += tmp;
  }
  cout << (sum - max - min) / (n - 2) << endl;
  goto loop;
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){
  int n,s[100],num,max=s[0],min=s[0];
  
  while(true){
    
  cin>>n;
  if(n == 0)break;
      num=0;
    
  for(int i=0;i<n;i++){
    cin>>s[i];
      
    if(max<s[i])max=s[i];
    if(max>s[i])min=s[i];
       
    num += s[i];
  }
  num = (num-max-min)/n;
    cout<<num<<endl;
    

    
  }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
//#define scanf scanf_s

int main()
{
	int n;
	while (cin >> n,n)
	{
		int max = 0; int min = INF;
		int sum = 0;
		REP(i, n)
		{
			int a;
			cin >> a;
			sum += a;
			if (a > max) max = a;
			if (a < min) min = a;
		}
		sum = sum - max - min;
		cout << sum / (n - 2) << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;

int judge(int n){
  int max=-1, min=1001, sum=0;
  vi s(n);
  rep(i, n){
    cin >> s[i];
    sum+=s[i];
    if(s[i]>max)max=s[i];
    if(s[i]<min)min=s[i];
  }
  return (sum-max-min)/(n-2);
}

int main(){
  int cnt=0;
  vi ans(20);
  rep(i, 20){
    int n;
    cin >> n;
    if(n==0)break;
    ans[i]=judge(n);
    cnt++;
  }

  rep(i, cnt){
    if(ans[i]==-1)break;
    cout << ans[i] << endl;
  }

  return 0;
}

C++: #include <iostream>
#include<algorithm>
using namespase std;
int main(){
int n;
cin>>n;
int sum =0;
int ma =0;
int mi =100000;
int cnt =0;
for(int i=0;i<n;i++){int s;cin>>s;sum+=s;ma =max(ma,s);mi=min(mi,s);cnt++;}
cout<<(sum-mi-ma)/(cnt-2)<<endl
}

C++: #include<stdio.h>

int main(){
  int i, n, s;

  while (1) {
    scanf("%d", &n);
    if (n==0) {
      break;
    }
    int ans = 0, maxv = 0, minv = 1000;
    int score[n];
    for (i = 0; i < n; i++) {
      scanf("%d", &s);
      if (s > maxv) {
        maxv = s;
      }
      if (s < minv) {
        minv = s;
      }
      score[i] = s;
    }

    for (i = 0; i < n; i++) {
      ans += score[i];
    }

    printf("%d\n", (ans-maxv-minv)/(n-2));
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int main{
  int a[2020];
  int i = 0;
  while (cin >> x){
    a[i++] = x;
  }
  saiten(a,0);
}
int saiten(a,j){
  int max = 0 , min = 0 , ave = 0;
  if (a[j] != 0){
    for (int k = j+1; k <= j+a[j]; k++;){
      if (max < a[k])
	max = a[k];
      if (min > a[k])
	min = a[k];
      ave += a[k];
    }
    ave = (ave - max - min)/(a[j]-2);
    cout << ave < endl;
    saiten(a, j+a[j]+1);
  }
}

C++: #include<iostream>
using namespace std;
int N, S;
int main(){
  while(cin >> N && N>0){
    int sum = 0;
    int min = 1001;
    int max = -1;
    for(int i=0;i<N;++i){
      cin >> S;
      sum += S;
      if(min>S) min = S;
      if(max<S) max = S;
    }
    int ans = (sum-max-min)/(N-2);
    cout << ans << endl;
  }
}

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

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

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int main() {
	int n;

	while(cin >> n, n) {
		vi score(n);
		int min=1000000, max=0, sum=0;

		REP(i, n) {
			cin >> score[i];
			if(score[i] < min) {
				min = score[i];
			}
			if(score[i] > max) {
				max = score[i];
			}
			sum += score[i];
		}

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

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

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

}

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

int main() {
	int n;//3<=n<=100
	int s;//0<=s<=1000
	int max,min,total,result;
	int i,finish=0;
	
	scanf("%d",&n);
	
	while(finish==0){
	max=0;
	min=1000;
	total=0;
	for(i=0;i<n;i++){
		scanf("%d",&s);
		if(s<min){min=s;}
		if(s>max){max=s;}
		total+=s;
	}
	result=(total-min-max)/(n-2);
	printf("%d\n",result);
	
	scanf("%d",&n);
	if(n==0){finish=1;}
	}
	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;
			if (m < min) min = m;
			answer += m;

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

	}

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  while(true){
    int n;
    scanf("%d",&n);
    if(n==0)break;
    vi a(n);
    REP(i,n)scanf("%d",&a[i]);
    sort(ALL(a));
    int sum = 0;
    FOR(i,1,n-1)sum += a[i];
    sum /= (n-2);
    printf("%d\n",sum);
  }
  return 0;
}