Go: package main

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

var (
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	for sc.Scan() {
		n, _ := strconv.Atoi(sc.Text())
		scores := make([]int, n, n)
		for i := 0; i < n; i++ {
			sc.Scan()
			scores[i], _ = strconv.Atoi(sc.Text())
		}
		sort.IntSlice(scores).Sort()
		var sum = 0
		for i := 1; i < n-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

C++: //#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;


// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T>
constexpr int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F>
constexpr int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T>
void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C>
void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U>
constexpr void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U>
constexpr void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C>
constexpr void reverse(C& c) { reverse(ALL(c)); }
template<typename C>
constexpr void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred>
constexpr void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9+7)
#pragma endregion


int main()
{
    int n;
    while(cin>>n) {
        if(n==0) break;
        vi v(n);
        rep(i,n) {
            cin >> v[i];
        }
        sort(v);
        remove(v,n-1);
        remove(v,0);
        P(accumulate(ALL(v),0)/v.size());
    }
    return 0;
}

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

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

using namespace std;


int a[1010];

int main(void){
	int n;
	while(1){
		cin >> n;
		if(n==0) break;
		rep(i,n) cin >> a[i];
		cout << (accumulate(a,a+n,0)-*max_element(a,a+n)-*min_element(a,a+n))/(n-2) << endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
    int n;

    while (true) {
        cin >> n;
        if (!n) break;
        vector<int> a(n);
        int sum = 0;
        for (int i = 0; i < n; ++i) cin >> a[i];
        sort(a.begin(), a.end());
        for (int i = 1; i < n-1; ++i) {
            sum += a[i];
        }
        cout << sum/(n-2) << endl;
    }
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n;
	while(cin>>n and n>0){
		int s[n]; rep(i,n) cin>>s[i];
		sort(s,s+n);
		int sum=0;
		for(int i=1;i<n-1;i++){
			sum+=s[i];
		}
		int ans=sum/(n-2);
		cout<<ans<<endl;
	}

	return 0;
}

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

using namespace std;

int main()
{
  int n;

  while(cin >> n, n){
    int mini = 114514, maxi = -114514;
    int sum = 0;

    for(int i = 0; i < n; i++){
      int s;
      cin >> s;
      sum += s;
      mini = min(mini, s);
      maxi = max(maxi, s);
    }
  
    cout << (sum - mini - maxi) / (n - 2) << endl;
  }
  
  return 0;
}

C++: #include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <utility>
#include <string>

using namespace std;

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

int main(){
    int n,tmp,maxN,minN;
    vector<int> ans;
    int tmpd;
    string num1,num2;
    while(1){
        cin>>n;
        if(n==0)break;
        tmpd=0;maxN=0;minN=1001;
        for(int i=0;i<n;i++){
            cin>>tmp;
            maxN = max(maxN,tmp);
            minN = min(minN,tmp);
            tmpd += tmp;
        }
        ans.push_back((tmpd-minN-maxN)/(n-2));

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

    return 0;
}

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

using namespace std;

int main(){

   while(1){
      int n;
      cin>> n;
      if(n==0){
         break;
      }
      int s[n];
      for(int i=0; i<n; i++) cin>> s[i];

      int sum=accumulate(s, s+n, 0);
      int mi=*min_element(s, s+n);
      int ma=*max_element(s, s+n);

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

   }

   return 0;
}

C++: #include <stdio.h>
int main()
{
  int n;
  while(scanf("%d", &n),n){
    int max=0,min=1000,s;
    long sum=0;
    for(int i=0; i<n; i++){
      scanf("%d",&s);
      sum+=s;
      max=max<s ? s : max;
      min=s<min ? s : min;
    }
    printf("%ld", (sum-min-max)/(n-2));
  }
}

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

int main()
{
	int in,a,maxer=0,miner=1000;
	int sum=0;
	int i=0;
	double ave=0.0;
	while( scanf("%d",&in) !=0 ){
		for(i=0; i<in; i++){
			cin >> a;
			maxer=max(a,maxer);
			miner=min(a,miner);
			sum += a;
		}
		sum = sum - maxer - miner;
		ave = sum/(in-2);
		cout << floor(ave) << endl;
		sum = maxer = ave = 0;
		miner=1000;
	}
}

C++: #include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
using namespace std;

#define ll long long
#define MP make_pair

int main(void) {
    int n;

    while(1){
        cin>>n;
        int s[100]={};
        double sum=0.0;
        if(n==0)break;

        for (int i = 0; i < n; i++) {
            cin>>s[i];
        }
        
        sort(s,s+n);
        for (int si = 1; si < n-1; si++) {
            sum+=double(s[si]);
        }
        
        double ave = sum/(double)(n-2);
        cout<<int(ave)<<"\n";

    }
    
    return 0;
}

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

int main(){

  
  int n;
  int sum;
  int s;
  int max,min;

  while(cin >> n){
    if(n==0){ break; }
    sum = 0;
    max=0,min=1000;

    for(int i=0; i<n; i++){
      cin >> s;
      if(s>max){ max=s; }
      if(s<min){ min=s; }

      sum += s;
    }

    sum -= max+min;

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

  }


  return 0;
}