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<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

#define M 1111111
int sosu[M];

int main(){
	
	while(1){
		int a;
		cin>>a;
		if(a==0)break;
		
		int b[1111]={0};
		
		rep(i,a){
			int c;
			cin>>c;
			b[c]++;
		}
		
		int ans = 0;
		int st = -1;
		int en = 0;
		rep(i,1111){
			if(b[i]!=0){
				if(st==-1)st=i;
				en = i;
				ans += i*b[i];
			}
		}
		
		ans -= st+en;
		printf("%d\n",ans/(a-2));
	}
}

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

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

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

void totalize(int n)
{
    int min = 1000, max = 0;
    int s, total = 0;
    for (int i = 0; i < n; i++) {
        cin >> s;
        total += s;
        if (s < min) {
            min = s;
        } else if (max < s) {
            max = s;
        }
    }
    cout << (total - max - min) / (n - 2) << endl;
}

int main()
{
    int n;
    while (true) {
        cin >> n;
        if (n == 0) {
            break;
        }
        totalize(n);
    }
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n1;
	cin >> n1;
	int a[100000] = { 0 };
	for (int i = 0; i < n1; i++){
		cin >> a[i];
	}
	sort(a, a + n1);
	a[0] = { 0 };
	a[n1 - 1] = { 0 };
	for (int i2 = 1; i2 < n1; i2++){
		a[0] += a[i2];
	}
cout << a[0] / (n1 - 2) << endl;
	return 0;
}

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

int main(){
	vector<int> ansvec;
	for (;;){
		int n;
		cin >> n;
		if (n == 0) break;

		int tmpmin = 1001;
		int tmpmax = -1;
		int tmpans = 0;
		for (int i = 0; i < n; i++){
			int s;
			cin >> s;
			tmpmin = min(s, tmpmin);
			tmpmax = max(s, tmpmax);
			tmpans += s;
		}
		tmpans -= (tmpmin + tmpmax);
		tmpans /= (n - 2);
		ansvec.push_back(tmpans);
	}

	for (int ans : ansvec){
		cout << ans << endl;
	}

	return 0;
}

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

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

  }
  return 0;
}

C++: #include <stdio.h>

int main(){
    int n,s[100]={0};
	int max,min,max1,min1;
	int sum,i;

scanf("%d",&n);

do{
	max=0;
	min=100000;
	sum=0;
	sum=0;
    max1=0;
    min1=0;
	for (i=0;i<n;i++){
		scanf("%d",&s[i]);
		if(s[i]>max){
            max=s[i];
			max1=i;
		}
		if(s[i]<min){
			min=s[i];
            min1=i;
		}
	}
	for(i=0;i<n;i++){
		if(i!=max1&&i!=min1){
			sum+=s[i];
		}
	}
	printf("%d\n",sum/(n-2));
	scanf("%d",&n);
}while (n!=0);
return 0;
}

C++: #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
template<class T> using vv=vector<vector<T> >;

int main() {
  vi results;

  while (true) {
    int count;
    cin >> count;
    if (count == 0) { break; }
    vi point(count);
    for (int i = 0 ; i < count ; i++) {
      cin >> point[i];
    }
    int max_point = -1;
    int min_point = 1001;
    int ave = 0;
    for (int i = 0 ; i < point.size() ; i++) {
      ave += point[i];
      if (max_point < point[i]) {
        max_point = point[i];
      }
      if (min_point > point[i]) {
        min_point = point[i];
      }
    }
    ave -= (max_point + min_point);
    ave /= (count-2);
    results.push_back(ave);
  }

  for (int i = 0 ; i < results.size() ; i++) {
    printf("%d\n", results[i]);
  }

  return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(void)
{
    while(1){
        int n;
        scanf(" %d", &n);
        if(n == 0)
            break;
        vector<int> s;

        for(int i = 0; i < n; i++){
            int tmp;
            scanf(" %d", &tmp);
            s.push_back(tmp);
        }
        sort(s.begin(), s.end());

        int sum = 0;
        for(int i = 1; i < n - 1; i++)
            sum += s[i];
        printf("%d\n", sum / (n-2));
    }
    return 0;
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const int INF = 10000;

struct edge{int to,cost;};
typedef pair<int,int> P;//firstは最短距離,secondは頂点番号


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

C++: using namespace std;
int main(){
	int n,t;
	while(cin>>n,n){
		int mx=0,mn=1000,s=0;
		for(int i=0;i<n;i++){
			cin>>t,s+=t;
			if(t>mx)mx=t;
			if(t<mn)mn=t;
		}
		cout<<(s-mx-mn)/(n-2)<<endl;
	}
	return 0;
}