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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    vector<int> avg;
    while(true) {
        int n;
        cin >> n;
        if(n==0)
            break;

        vector<int> v(n);
        int sum = 0;
        int ma = -1;
        int mi = 10000;
        for(int i=0;i<n;i++) {
            int vi;
            cin >> vi;
            ma = max(ma, vi);
            mi = min(mi, vi);
            sum += vi;
        }

        sum = sum - ma - mi;
        avg.push_back(sum/(n-2));
    }
    for(int i=0;i<avg.size();i++)
        cout << avg[i] << endl;
}

C++: #include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1) {
		ll n;
		cin>>n;
		if(n==0) break;
		vector<ll> s(n);
		REP(i,n) cin>>s[i];
		sort(ALL(s));
		ll sum=accumulate(ALL(s),0);
		sum-=s[0]+s[n-1];
		cout<<sum<<endl;
	}
}

C++: #include <iostream>
using namespace std;
 
int main() {
	int n;
	while(1){
	cin >> n;
	if(n==0)break;
	int min,max;
	int s,x;
	cin >>s;
	min=s;
	max=s;
	x=s;
		for(int i=0;i<n-1;i++){
		cin >>s;
		x=x+s;
		if(min >s) min=s;
		if(max <s) max=s;
 
		}
	x=x-max-min;
    x=x/(n-2);
	cout << x <<endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#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 <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define clear(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


int main()
{
	int n;
	while (cin >> n, n)
	{
		int s[1024];
		rep (i, n)
			cin >> s[i];
		sort(s, s + n);
		cout << accumulate(s + 1, s + (n - 1), 0) / (n - 2) << endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a;
    while (cin>>n) {
        if (n==0) {
            break;
        } else {
            std::deque<int> deq;
            for (int i=0;i<n;i++) {
                cin>>a;
                deq.emplace_back(a);
            }
            sort(deq.begin(),deq.end());
            deq.erase(deq.begin(),deq.begin()+1);
            sort(deq.begin(),deq.end(),greater<int>());
            deq.erase(deq.begin(),deq.begin()+1);
            int sum=0;
            for (int j=0;j<deq.size();j++) {
                sum+=deq[j];
            }
            int ave=floor(sum/(n-2));
            cout<<ave<<endl;
        }
    }
}

C++: #ifndef _WIN32
#include<iostream>
#endif
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<string>
#include<stdlib.h>

using namespace std;
#define rep(i,n) for(auto i=(n)*0;i<n;i++)
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	cout << fixed << setprecision(30);
	int n;
	while (cin >> n, n){
		int top = 0, bottom = 1000,sum=0;
		rep(i, n){
			int s;
			cin >> s;
			sum += s;
			top = max(top, s);
			bottom = min(bottom, s);
		}
		cout << (sum - top - bottom)/(n-2) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <sstream>
#include <algorithm>

using namespace std;


int main () {
	while (true) {
		int n;
		cin >> n;
		if (n == 0) break;
		vector<int> v;
		int count = 0;

		for(int i = 0; i < n; i++){
			int a;
			cin >> a;
			count+=a;
			v.push_back(a);
		}
		sort(v.begin(),v.end());
		count-=v[0];
		count-=v[v.size()-1];
		cout << count/(n-2) << endl;
	}
	
	return 0;
}

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

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

  }
  return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
  while(1){
    int n;
    cin >> n;
    if(n == 0)break;
    vector<int> array(n,0);
    int max_a = 0;
    int min_a = 10000;
    
    for(int i = 0;i < n;i++){
      int tmp;
      cin >> tmp;
      max_a = max(max_a,tmp);
      min_a = min(min_a,tmp);
      array[i] = tmp;
    }
    int sum = 0;
    for(int i = 0; i < n;i++){
      if(array[i] != max_a && array[i] != min_a)sum += array[i];
    }
    cout << (int)(sum / n-2) << endl;
  }
  return 0;
}

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

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

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

int n;
int s[128];

int main() {
  for(;;) {
    scanf("%d", &n);
    if( n == 0 ) break;
    for(int i = 0; i < n; ++i) {
      scanf("%d", &s[i]);
    }
    std::sort(s, s + n);
    int total = 0;
    for(int i = 1; i < (n - 1); ++i) {
      total += s[i];
    }
    total /= (n - 2);
    printf("%d\n", total);
  }

  return 0;
}