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>

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {
	int result[100] = {};
	int pos = 0;
	while (1) {
		int n;
		int s[101] = {};
		int mini = 1001;
		int maxi = -1;
		int total = 0;

		cin >> n;
		if (n == 0) {
			break;
		}
		pos++;
		FOR(i, 1, n) {
			cin >> s[i];
			if (maxi < s[i]) {
				maxi = s[i];
			}
			else if (mini > s[i]) {
				mini = s[i];
			}
			total += s[i];
		}
		result[pos] = (total - maxi - mini) / (n - 2);
	}
	FOR(i, 1, pos) {
		cout << result[i] << endl;
	}

}

C++: #include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
#include <fstream>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define sz(x) ((int)(x).size())

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
const ll MOD = 1000000007;
//const ll MOD = 998244353;
double EPS = 1e-10;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.12lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

void solve(){
  while(true){
    int n;
    cin >> n;
    if(n == 0) return;
    int sum = 0;
    int Ma = -1, mi = INF;
    rep(i, n){
      int a;
      cin >> a;
      sum += a;
      Ma = max(Ma, a);
      mi = min(mi, a);
    }
    sum -= Ma + mi;
    cout << sum / (n-2) << endl;
  }
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  solve();
}

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

int main() {
    for(int n; scanf("%d", &n),n;) {
        int sum=0,miv=1000,mav=0;
        for(int i = 0; i < n; i++) {
            int s; scanf("%d", &s);
            sum+=s;
            miv=min(miv,s);
            mav=max(mav,s);
        }
        printf("%d\n", (sum-miv-mav)/(n-2));
    }
    return 0;
}

C++: #include<iostream>
#include<deque>
#include<algorithm>
#include<numeric>
using namespace std;
int main()
{
	int n,s;
	while(cin>>n,n)
	{
		deque<int>d(n);
		while(n--)cin>>s,d[n]=s;
		sort(d.begin(),d.end());
		d.pop_back(),d.pop_front();
		cout<<accumulate(d.begin(),d.end(),0)/d.size()<<endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
int main()
{
	int n;
	while(1)
	{
		cin >> n;
		if(n==0)break;
		vector<int> vec(n);
		for(int i=0;i<n;i++)cin >> vec[i];
		sort(all(vec));
		cout << accumulate(vec.begin()+1,vec.end()-1,0)/(n-2) << endl;
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int main () {
  while (true){
    int n,i;
    int s = 0;
    int mi = 0;
    int ma = 0;
    cin >> n;

    if (n == 0)
      break;
??????
??????int point[n];

    for (i=0,i<n,i++){
      cin >> point[i];

      if (point[i] < mi)
        mi << point[i];

      if (point[i] > ma)
        ma << point[i];

      s += point[i];
    }

    cout << (s - mi - ma) / (n-2) << endl
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int N, S;
int main()
{
	/* code */
	while (cin >> N && N >0){
		int sum = 0;
		for(int i=0; i<N; i++){
			cin >> S;
			sum += S;
		}
		cout << sum << endl;
	}

}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <sstream>
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;

const int MAX_s = 1005;
int n, m, M, S, s;

int main() {
    while(true) {
        cin >> n;
        if(n == 0) {
            break;
        }

        S = 0;
        m = MAX_s;
        M = 0;
        for(int i = 0; i < n; i++) {
            cin >> s;
            S += s;
            m = min(m, s);
            M = max(M, s);
        }

        cout << (int)((S - m - M) / (n - 2)) << endl;
    }

    return 0;
}

C++: #include <iostream>
using namespace std;
int N,S;
int main() {
 while (cin >> N && N>0) {
  int max = 0;
  int min = 1000;
  int sum = 0;
  int answer;
  for (int i=0; i<N; ++i) {
   cin >> S;
   sum += S;
   if(max < S) max = S;
   if(min > S) min = S;
  }
  answer = (int)((sum-max-min)/(N-2));
  cout << answer << endl;
 }
}

C++: #include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    
    /////////
    //write//
    /////////
    
    while (1){
        int n; cin >> n;
        if(n==0)break;
        int s[1000] = {0};
        for(int i=0; i<n; i++){
            cin >> s[i];
        }
        
        sort(s, s+n);
        
        int sum = 0;
        for(int i=1; i<n-1; i++){
            sum+=s[i];
        }
        sum/=(n-2);
        
        cout << sum << endl;
    }
    return 0;
}

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

int main(){
	int n;
	while (std::cin >> n && n){
		std::vector<int> score;
		for (int i = 0; i < n; ++i){
			int s;
			std::cin >> s;
			score.push_back(s);
		}
		std::sort(score.begin(), score.end());
		score.pop_back();
		score.erase(score.begin());
		int ans = 0;
		int cnt = 0;
		for (auto it = score.begin(); it != score.end(); ++it){
			ans += *it;
			cnt++;
		}
		std::cout << ans/cnt << std::endl;
	}
	return 0;
}