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 <climits>
#include <cstdlib>
#include <iostream>
using namespace std;

template<class T> inline void chmax(T& a, T b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, T b) { if(b < a) a = b; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	for(int n; cin >> n, n;) {
		int sum = 0, mx = 0, mn = INT_MAX;
		for(int i = 0; i < n; ++i) {
			int score;
			cin >> score;
			sum += score;
			chmax(mx, score);
			chmin(mn, score);
		}

		cout << (sum - mx - mn) / (n - 2) << endl;
	}

	return EXIT_SUCCESS;
}

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

int main(void){
    int n,s,sum=0,i=0;
    int ma=0;
    int mi=10000;
    while(true){
        cin>>n;
        sum=0;
        i=0;
        ma=0;
        mi=10000;
        if(n==0)break;
        //cout<<n<<endl;
        while(i<n){
            cin>>s;
            ma=max(ma,s);
            mi=min(mi,s);
            sum+=s;
            i++;
        }
        sum=sum-ma-mi;
        cout<<sum/(n-2)<<endl;
    }
    return 0;
}

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

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


int main()
{
        int n;
        while (cin >> n, n) {
                vector<int> vs = vector<int>(n);
                rep(i, n) cin >> vs[i];
                sort(vs.begin(), vs.end());
                int ans = 0;
                REP(i, 1, n-1)
                        ans += vs[i];
                ans /= n-2;
                cout << ans << endl;
        }
        return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
//#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    for (int n; cin >> n && n;) {
        VI s(n); cin >> s;
        cout << (accumulate(all(s), 0) - *max_element(all(s)) - *min_element(all(s))) / (n - 2) << "\n";
    }
}

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

using namespace std;

int main(){

  

  int n;

  while(cin>>n){

    if(n==0){
      cout<<endl;
      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){
        int p=0;
        vector<int> a;
        a.resize(n);
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        sort(a.begin(),a.end());
        
        for(int i=1;i<n-1;i++){
            p+=a[i];
        }
        cout << p/(n-2) << endl;
    }

	return 0;
}

C++: #include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

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

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n;
	while (cin >> n, n != 0) {
		vi s(n);
		int sum = 0;
		rep(i, 0, n) {
			cin >> s[i];
			sum += s[i];
		}
		sum -= *max_element(all(s)) + *min_element(all(s));
		cout << sum / (n - 2) << endl;
	}
}

C++: #include<stdio.h>
int main(void) {
	int n, s[100] = {0}, max, min,sum=0,count=0;
	scanf("%d", &n);
	for (int i = n; i > 0; i--) {
		scanf("%d", &s[i]);
		if (i == n) {
			max = s[i];
			min = s[i];
		}
		if (max < s[i]) max = s[i];
		if (min > s[i]) min = s[i];
		count++;
		if (s[i] == 0) break;
		sum += s[i];
	}
	sum = sum - (max + min);
	printf("%d", sum/(count-2));
	return 0;
}