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<stdio.h>

void QSort(int x[ ], int left, int right);
void Swap(int x[ ], int i, int j);

void QSort(int x[ ], int left, int right)
{
    int i, j;
    int pivot;

    i = left;                   
    j = right;                  

    pivot = x[(left + right) / 2];
    while (1) {                   

        while (x[i] < pivot)      
            i++;                  

        while (pivot < x[j])      
            j--;                  
        if (i >= j)               
            break;                

        Swap(x, i, j);            
        i++;                      
        j--;
    }

    if (left < i - 1)              
        QSort(x, left, i - 1);     
    if (j + 1 <  right)            
				QSort(x, j + 1, right);    
		}

void Swap(int x[ ], int i, int j)
{
    int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}

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

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

		QSort(p,0,n-1);	
	
		sum = 0;
		for(i=1;i<n-1;i++)
			sum += p[i];
	
			j = 0;
			d[j] = sum / (n-2);
			j++;
	}
	
	for(k=0;k<j;k++){
		printf("%d",d[k]);
	}
	
	return 0;
}

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

int main() {
	int n, max, min, s;
	long sum;

	while (true) {
		cin >> n;
		sum = max = 0;
		min = 1000;

		if (n == 0)	break;

		for (int i = 0; i < n; i++) {
			cin >> s;
			if (s < min)	min = s;
			if (s > max)	max = s;
			sum += s;
		}
		sum -= (min + max);
		cout << sum / (n - 2) << endl;
	}
	return 0;
}

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

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

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

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

C++: #include<stdio.h>
#include<stdlib.h>

int main(){
  int s;
  int n;
  int i;
  int ans=0;
  while(1){
    scanf("%d",&n);
    if(n==0){break;}
    for(i=0;i<n;i++){
      int k;
      scanf("%d",&k);
      ans+=k;
    }  
    printf("%d\n",ans);
  }

}

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

int main(){
	int n;
	while(cin >>n){
		if(n == 0) break;
		vector<int> vec;
		int tmp, max, min;
		cin >>tmp;
		vec.push_back(tmp);
		max = tmp;
		min = tmp;
		bool maxb = true, minb = true;
		for(int i = 1; i < n; i++){
			cin >>tmp;
			vec.push_back(tmp);
			if(tmp < max) max = tmp;
			if(tmp > min) min = tmp;
		}
		int sum = 0;
		for(int i = 0; i < vec.size(); i++){
		if(vec[i] == max && maxb){
			maxb = false;
		} else if(vec[i] == min && minb){
			minb =false;
		} else{
			vec[i] += sum;
		}
		cout <<sum <<endl;
		return 0;
	}
}

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

C++: #include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

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

C++: int main() {
	while(true){
		int number;			//?????£??????????????°
		cin >> number;
		if(number == 0){exit(0);}

		int score[number];
		int i;
		for(i=0;i<number;i++){	//???????????????
			cin >> score[i];
		}

		int max = 0;			//????????????
		int maxJ;				//?????????????????????????????£??????
		int min = 1001;
		int minJ;
		for(i=0;i<number;i++){	//??????????????¨????°??????????????????????
			if(max < score[i]){
				maxJ = i;
			}
			if(score[i] < min){
				minJ = i;
			}
		}

		int sum = 0;
		for(i=0;i<number;i++){
			if(i != maxJ && i != minJ){
				sum += score[i];
			}
		}
		cout << sum << endl;

	}
	return 0;
}

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

int main() {

  long N;
  std::vector<long> v;
  long temp;
  long ans;
  long total;

  for(;;) {
    v.clear();
    std::cin >> N;
    if( N == 0 ) break;
    for(int i = 0; i < N; ++i) {
      std::cin >> temp;
      v.push_back(temp);
    }
    std::sort(std::begin(v), std::end(v));
    total = 0;
    for(int i = 1; i < N-1; ++i) total += v[i];
    ans = total / (N-2);
    std::cout << ans << std::endl;
  }


  return 0;
}

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 <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-8;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};



main(){
  int n;
  while(cin>>n,n){
    vector<int> in;
    int sum=0;
    rep(i,n){
      int t;
      cin>>t;
      sum+=t;
      in.pb(t);
    }
    sort(ALL(in));
    sum-=in[0]+in.back();
    cout<<sum/(n-2)<<endl;
    
    
  }
}

C++: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename T = int>inline T in() { T x; cin >> x; return x; }
#define REP(i,n) for(ll i=0;i<(n);++i)
#define REP1(i,n) for(ll i=1;i<=(n);++i)
#define REPI(i,ini,n) for(ll i=(ini);i<(n);++i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b) (((a)+(b)-1)/(b))
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1e9
#define INFL static_cast<ll>(INF)
int main()
{
	while (true)
	{
		int n = in();
		if (n == 0)break;
		vector<int>s(n);
		REP(i, n)s[i] = in();
		sort(ALL(s));
		int sum = 0;
		REP1(i, s.size() - 2)sum += s[i];
		cout << sum / (n - 2) << endl;
	}
}