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())
		if n == 0 {
			break
		}
		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 < len(scores)-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

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

int main(void){
	
	int n,i,flag;
	int max,min;
	int readed,ans;
	double avg;
	
	while(1){
		
		flag = 0;
		
		scanf(" %d",&n);
		
		if(n==0){
			break;
		}
		
		for(i = 0;i < n;i++){
			
			scanf(" %d",&readed);
			
			if(flag == 0){
				max = readed;
				min = readed;
				flag = 1;
			}
			
			if(max < readed){
				max = readed;
			}
			
			if(min > readed){
				min = readed;
			}
			
			avg += readed;
		}
		
		avg -= max + min;
		
		avg /= n - 2;
		
		ans = (int)floor(avg);
		
		printf("%d\n",ans);
		
	}
	
	return(0);
	
}

C++: #include <iostream>

using namespace std;

int main() {
  int n;
  while (cin >> n, n) {
    int sum = 0, minv = 1000, maxv = 0;
    for (int i = 0; i < n; i++) {
      int s;
      cin >> s;
      maxv = max(maxv, s);
      minv = min(minv, s);
      sum += s;
    }
    sum -= maxv + minv;
    cout << sum / (n - 2) << endl;
  }
  return 0;
}

C++: #include <iostream>

int main()
{
    int n, s = 0;
    std::cin >> n;

    int max, min, sum = 0;
    std::cin >> s;
    max = s;
    min = s;
    sum += s;

    for (int i = 0; i < n - 1; i++) {
        std::cin >> s;
        if (s > max)
            max = s;
        if (s < min)
            min = s;
        sum += s;
    }
    std::cout << (sum - max - min) / (n - 2) << '\n';

    return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
  while (true) {
    int n;
    cin >> n;
    if (n == 0)
      break;

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

    sort(score + 0, score + n);
    int sum = accumulate(score + 1, score + n - 1, 0);

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

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


main(){
	int i,n,sum,mmin,mmax,t;
	while(cin>>n,n){
		sum=0;mmin=1000;mmax=0;
		for(i=0;i<n;i++){
			cin >> t;
			sum+=t;
			mmin = min(mmin,t);
			mmax = max(mmax,t);
		}
		cout << (sum-mmin-mmax)/(n-2) << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
	int a[20];
	int b,sum=0,point;
	while(1){
		cin >> b;
		if(b==0) break;
		for(int i=0;i<b;i++){
			cin >> a[i];
			
		}
		sort(a,a+b);
		for(int j=1;j<b-1;j++){
			sum+=a[j];
		}
		point=sum/(b-2);
		cout << point << endl;
		sum=0;
		
	}
	return 0;
}

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

int main(){
	int n;
	while(scanf("%d",&n),n){
		vector < int > vi;
		for(int i = 0; i < n; i++){
			int tmp;
			scanf("%d",&tmp);
			vi.push_back(tmp);
		}
		sort(vi.begin(),vi.end());
		double ave = 0.0;
		for(int i = 1; i < n-1 ;i++){
			ave += vi[i];
		}
		printf("%.0lf\n",ave/(n-2));
	}
	return 0;
}

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


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

  return 0;
}

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

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

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

int n,s[100];
int temp,ave,sum;

void sort(void){
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      if(s[i]>s[j]){
	temp=s[i];
	s[i]=s[j];
	s[j]=temp;
      }
    }
  }
}

int main(){
  while(cin >> n,n){
    for(int i=0;i<n;i++)
      cin >> s[i];  
    
    sort();
    
    sum=0;

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

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

C++: #include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e18;
const int inf=2e9;
const ll MOD=1000000007;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};

int main(){
    while(true){
        int N;cin>>N;
        if(N==0)break;
        int info[N];
        rep(i,N)cin>>info[i];
        sort(info,info+N);
        int sum=0;
        rep(i,N-2)sum+=info[i+1];
        int ans=sum/(N-2);
        cout<<ans<<endl;
    }
    return 0;
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#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<climits>
using namespace std;

//conversion
//------------------------------------------
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(); }

//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 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(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int getAverageScore(int N, VI S){
	int min = S[0];
	int max = S[0];
	int sum = 0;
	FOR(i, 0, N){
		sum += S[i];
		if (min >= S[i]){ min = S[i]; }
		if (max <= S[i]){ max = S[i]; }
	}
	sum -= min;
	sum -= max;
	return sum / (N-2);
}
int main(){
	int N;
	VI S;
	int b;
	int c = INT_MAX;
	while (true){
		cin >> N;
		if (N == 0){ break; }
		if (c != INT_MAX){ cout << endl; }
		REP(i, N){
			cin >> b;
			S.push_back(b);
		}
		c = getAverageScore(N, S);
		cout << c;
		S.clear();
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
using std::cin;
using std::cout;
using std::endl;


int main(){
  int n;
  int k;
  int sum=0;
  int max;
  int min;
  while(cin >> n){
    sum = 0;
    if(n == 0){
      break;
    }
    for(int i = 0;i < n;i++){
      cin >> k;
      if(i==0){
        min = k;
        max = k;
      }else if(min > k){
        min = k;
      }else if(max < k){
        max = k;
      }
      sum += k;
    }
    sum = (sum - min - max)/(n-2);
    cout << sum << endl;
  }
}