Go: // ICPC 得点集計ソフトウェア
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for	{
		n := nextInt(sc)
		if n == 0 { break }

		score_list := []int{}
		for i := 0; i < n; i++ {
			score_list = append(score_list, nextInt(sc))
		}

		// 最低点と最高点を取り除く (3 ≤ n ≤ 100)
		sort.Sort(sort.IntSlice(score_list))
		score_list = score_list[1:len(score_list)-1]

		// 平均点を求める
		sum := 0
		for _, score := range score_list {
			sum += score
		}
		fmt.Println(sum / len(score_list))
	}
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

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, 1, N){
		sum += S[i];
		if (min > S[i]){ min = S[i]; }
		if (max < S[i]){ max = S[i]; }
	}
	sum -= (min + 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>

using namespace std;

int main(){

  int n;

  while(cin>>n){



    if(n==0){
      break;
    }
    int a[n];
    int max,min;

    max=0;
    min=1000;

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

      if(a[i]>max){
	max=a[i];
      }

      if(a[i]<min){
	min=a[i];
      }
    }

    int sum;

    sum=0;

    for(int p=0;p<n;p++){
      sum=sum+a[p];
    }

    sum=sum-max-min;

  

    cout << sum/(n-2) << endl; 

   

  }

  



  return 0;
}

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

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

     return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    while(1){
        int mn=1000000,mx=0;
        int sum=0,a;
        cin>>n;
        if(n==0){break;}
        for(int i=0;i<n;i++){
            cin>>a;
            mx=max(a,mx);
            mn=min(a,mn);
            sum+=a;
        }
        sum-=mx;
        sum-=mn;
        cout<<sum/(n-2)<<endl;
    }
        
    return 0;
    
}

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

int main() {
	int i, n, tmp, sum;
	priority_queue<int> q;
	while (1) {
		cin >> n;
		if (n == 0)break;
		sum = 0;
		for (i = 0; i < n; i++) {
			cin >> tmp;
			q.push(tmp);
		}
		q.pop();
		while (q.size() > 1) {
			sum += q.top();
			q.pop();
		}
		q.pop();
		cout << sum / (n - 2) << endl;
	}





	return 0;
}

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

int main(){

	int n;
	while(cin >> n, n){
		vector<int> score;
		for(int i=0; i<n; i++){
			int s; cin >> s;
			score.push_back(s);
		}
		sort(score.begin(), score.end());
		int sum = accumulate(score.begin(), score.end(),0);
		cout << ( sum - score.back() - score.front() )/ (score.size()-2) << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
  int n;
  int point[20], average;
  
  while(1){
    average = 0;
    cin >> n;
    if(n == 0) break;

    for(int i = 0 ; i < n ; i++){
      cin >> point[i];
    }
    sort(point, point + n);
    if(n >= 3){
      for(int i = 1 ; i < n - 1 ; i++){
	average += point[i];
      }
    }
    if(n >= 3) average /= (n-2);
    cout << average << endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
    int n, s[1000];
    while(cin >> n && n > 0){
        int  max = 0, min = 10000, sum = 0;
        for (int i = 0; i < n; i++){
            cin >> s[i];
            sum += s[i];
        }
        for (int i = 0; i < n; i++){
            if (s[i] > max)
                max = s[i];
        }
        for (int i = 0; i < n; i++){
            if (s[i] < min)
                min = s[i];
        }
        cout << (sum - max - min)/(n - 2) << endl;
    }
}

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

int N, S;

int main()
{
   while ( cin >> N && N>0)
   {
      int M = -1, m = 1001 ,addup = 0;
      for ( i = 0; i<N; i++)
      {
         cin >> S;
         addup += S;
         if ( S > M) M = S;
         if ( S < m) m = S;
      }
   }
   cout << (addup - M - m)/(n-2)  << endl;
}

C++: #include <iostream>

using namespace std;

#define min(a, b) ((a)<(b)? (a):(b))
#define max(a, b) ((a)>(b)? (a):(b))

int main() {
	while(true) {
        int n; cin >> n;
        if(n == 0) break;
	    int sum = 0, s_min = 1024, s_max = -1;
	    for(int i=0; i<n; i++) {
	        int s; cin >> s;
	        sum += s;
	        s_min = min(s_min, s);
	        s_max = max(s_max, s);
	    }
	    cout << (sum - s_min - s_max) / (n - 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<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

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

  cout << ave << endl;
  }
  return 0;

}