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 <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define LOOP(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) LOOP(i, 0, n)
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359

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

  for(int i=0; i<ans.size(); i++) {
    cout << ans[i] << endl;
  }

  return 0;
}

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

int main(){
	int N,n,sum;
	vector<int> point;
	while(1){
		cin>>N;
		if(N==0) break;
		sum=0;

		while(!point.empty()){
			point.pop_back();
		}

		for(int i=0;i<N;i++){
			cin>>n;
			point.push_back(n);
		}

		sort(point.begin(),point.end());

		for(int i=1;i<point.size()-1;i++){
			sum+=point[i];
		}
		cout<<sum/(point.size()-2)<<endl;
	}
	return 0;
}

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

int main() {
	while (1) {
		int n, maxn, minn;
		int pn = 0;
		cin >> n;
		if ( n == 0 ) break;
		int s[n];
		for (int i = 0; i < n; i++) {
			cin >> s[i];
			if ( i == 0 ) {
				maxn = s[0];
				minn = s[0];
			} else {
				if ( s[i] > maxn ) maxn = s[i];
				if ( s[i] < minn ) minn = s[i];
			}
			pn += s[i];
		}
		cout << (pn - maxn - minn) / (n - 2);
	}
	return 0;
}

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

int main(){
	int n;

	while (cin >> n, n){
		int a[100], sum = 0;
		for (int i = 0; i < n; i++){
			cin >> a[i];
		}
		int sum = accumulate(a, a + n, 0);
		int Max = *max_element(a, a + n);
		int Min = *min_element(a, a + n);
		cout << (sum - (Max + Min)) / (n - 2) << endl;
	}
	return 0;
}

C++: #include<algorithm>
using namespace std; 
int main(){
  int n;  
  while(cin>>n&&n!=0){
    cin>>n;
    int a[]={};
    int sum=0;
    for(int i=0;i<n;i++){    
      int b;
      cin>>b;
      a[i]=b;
      sum+=b;
    }
    sort(a,a+n);
    sum-=a[0];
    sum-=a[n-1];
    cout<<sum/(n-2)<<endl;
  }

  return 0;
}

C++: #include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string>
#include<utility>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

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

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
    
    cin.tie( 0 );
    ios::sync_with_stdio( false );
    
    while(true){
        int n;
        cin >> n;
        
        if(n == 0){ break; }
        vector<int> vc(n);
        
        for(int i=0; i<n; i++){
            cin >> vc[i];
        }
        sort(vc.begin(), vc.end());
        auto res = (accumulate(vc.begin() + 1, vc.end() -1, 0));
        cout << res / (n-2) << endl;
    }
    return 0;
}

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

int main()
{
	int N, n, sum, largest, smallest;
	sum  = 0; largest = 0; smallest = 1000;
	
	while(cin >> N; && N>0){
		for(int i = 0; i<N; i++)
		{
			cin >> n;
			sum += n;
			
			if(smallest > n){ smallest = n;}
			if(largest < n){ largest = n;}
		}
	
		cout << (sum-smallest-largest)/(N-2) << endl;
	}
}

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

using namespace std;

int main(){
	while(true){
		int n;
		cin >> n;
		if(n == 0){ break; }
		int minval = INT_MAX, maxval = 0, sum = 0;
		for(int i = n; i > 0; --i){
			int s;
			cin >> s;
			minval = min(s, minval);
			maxval = max(s, maxval);
			sum += s;
		}
		cout << (sum - minval - maxval) / (n - 2) << endl;
	}
	return 0;
}

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

int main(){
  int n,a[21],b[21];
  while(1){
    
    cin>>n;
    if(n==0) break;
    for(int i=0;i<n;i++){
      cin>>a[i];
    }
    
    int max=0,min=10001;
    for(int i=0;i<n;i++){
      if(max<a[i]){
	max=a[i];
      }
      if(min>a[i]){
	min=a[i];
      }
    }
    
    int sum=0;
    for(int i=0;i<n;i++){
      sum+=a[i];
    }
    sum-=(max+min);
    
    cout<<sum/(n-2)<<endl;
  }
  return 0;
}

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

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

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

using namespace std;

int main(){
	vector<int> array;
	int i,x,max,min,sum,n;
	max = 0;
	min = 1000;

	while(cin>>n){
	array.clear();
	sum=0;

	for(i=0;i<n;i++){
		cin >> x;
		array.push_back(x);
	}
	for(i=0;i<n;i++){
		if(max<array[i]){
			max= array[i];
		}
	}
	for(i=0;i<n;i++){
		if(min>array[i]){
			min= array[i];
		}
	}
	for(i=0;i<n;i++){
		sum += array[i];
	}
	sum = sum-max-min;
	cout << sum/n << endl; 
	}

}

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

using namespace std;

int main()
{
    int n;

    while (cin >> n, n) {
        int ans = 0, s;
        int max_s, min_s;

        max_s = 0;
        min_s = 1000;
        for (int i = 0; i < n; i++) {
            cin >> s;

            ans += s;
            max_s = max(max_s, s);
            min_s = min(min_s, s);
        }

        cout << (ans - max_s - min_s) / (n - 2) << endl;
    }

    return 0;
}

C++: #include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
signed main() {
  int N;
  while (cin>>N,N!=0){
    int ma = 0, mi = INF;
    int ans=0;
    for(int i=0;i<N;i++){
      int t;cin>>t;
      ma=max(ma,t);
      mi=min(mi,t);
      ans+=t;
    }
    ans-=ma+mi;
    N-=2;
    ans/=N;
    cout<<ans<<endl;
  }
}