Go: package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	for n != 0 {
		arr := make([]int, n)
		for i := range arr {
			fmt.Scan(&arr[i])
		}
		sort.Ints(arr)

		sum := 0
		for i := 1; i < len(arr)-1; i++ {
			sum += arr[i]
		}
		fmt.Println(sum / (n - 2))
		fmt.Scan(&n)
	}
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
int main(){
  int n;
  while(cin >> n, n!=0){
    vector<int> s;
    int input = 0;
    for(int i=0; i<n; i++){
      cin >> input;
      s.push_back(input);
    }
    sort(s.begin(), s.end());
    int sum = 0;
    for(int i=1;i<n-1;i++){
      sum += s[i];
    }
    cout << floor(sum/(n-2)) << endl;
    s.clear();
  }
  return 0;
}

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

using namespace std;

int main(){
  vector<vector<int>> s;
  int n[100]={};
  int ma[100]={};
  vector<int> mi(100,1000);
  int tmp,c = 0;
  for(int i=0;i<100;i++){
    cin >> n[i];
    if(!n[i])break;
    s.push_back(vector<int>());

    for(int j=0;j<n[i];j++){
      cin >> tmp;
      s[i].push_back(tmp);
      ma[i] = max(ma[i],tmp);
      mi[i] = min(mi[i],tmp);
    }
    c++;
  }
  int ans;
  for(int i=0;i<c;i++){
    ans = floor((accumulate(s[i].begin(),s[i].end(),0) - ma[i] - mi[i])/(s[i].size()-2));
    cout << ans << endl;
  }


  return 0;
}

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

#define FOR(i,l,n) for(int i=(l);i<(n);i++)
#define REP(i,n) FOR(i,0,n)
#define MAX_JUDGE 100
using namespace std;

int main(){
  int n,score[MAX_JUDGE];
  while(cin>>n,n){
    REP(i,n)cin>>score[i];
    sort(score,score+n);
    int sum=0;
    FOR(i,1,n-1)sum+=score[i];
    cout << sum/(n-2);
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

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

C++: #include<stdio.h>

int main(){

int n;
int P[102]={};
while(1){
scanf("%d",&n);if(n==0)break;
for(int i=0;i<n;i++)
scanf("%d",&P[i]);

int s=0;
for(int i=0;i<n;i++)
for(int j=n-1;j>i;j--)
if(P[j]>P[j-1]){int t=P[j];P[j]=P[j-1];P[j-1]=t;}

for(int i=0;i<n;i++)
if(i!=0&&i!=n-1)s+=P[i];

s=s/(n-2);
printf("%d\n",s);
}
return 0;
}

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

int main(){
	
	while(1){
		
		int n,s[100],m=1000,M=0,sum=0;
		cin>>n;
		if(n==0)break;
		
		for(int i=0;i<n;i++)cin>>s[i];
		
		for(int i=0;i<n;i++){
			sum+=s[i];
			if(s[i]<m)m=s[i];
			if(s[i]>M)M=s[i];
		}
		
		cout<<(sum-m-M)/(n-2)<<endl;
	}
	return 0;
}

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

using namespace std;

int n;
int s[100]={};
int count = 0;
int dai,syou;
int ans[1000]={};
int judge = 0;

int main()
{
    while(1){
        scanf("%d",&n);
        if(n == 0){
            break;
        }
        dai = 0;
        syou = 1000;
        for(int i=0;i<n;i++){
            scanf("%d",&s[i]);
            if(dai <= s[i]){
                dai = s[i];
            }
            if(syou >= s[i]){
                syou = s[i];
            }
        }
        int dai_count = 0;
        int syou_count = 0;
        for(int i=0;i<n;i++){
            if(s[i]==dai && dai_count ==0){
                dai_count=1;
                
            }else if(s[i] == syou && syou_count ==0){
                syou_count = 1;
            }else{
                ans[judge] += s[i];
            }
        }
        ans[judge] = ans[judge] / (n-2);
        
        judge++;

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

    
    return 0;
}

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

#define FOR(i,l,n) for(int i=(l);i<(n);i++)
#define REP(i,n) FOR(i,0,n)
#define MAX_JUDGE 100
using namespace std;

int main(){
  int n,score[MAX_JUDGE];
  while(cin>>n,n){
    REP(i,n)cin>>score[i];
    sort(score,score+n);
    int sum = accumulate(score+1,score+n-2,0);
    cout << sum/(n-2) <<endl;
  }
  return 0;
}

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

C++: 
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

		int buf; cin >> buf;

		int mi = buf; int ma = buf;

		int sum = buf;
		for (int i = 1; i < n; i++) {
			cin >> buf;
			sum += buf;
			mi = min(mi, buf);
			ma = max(ma, buf);
		}

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

C++: //#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <climits>

using namespace std;
using ll=long long;

void solve(){
  while(true){
  int num;
  cin >> num;if(num==0){return;}
  int ma=0,mi=10000,sum=0;
  for(int i=0;i<num;i++){
    int c=0;
    cin >> c;
    ma=max(ma,c);
    mi=min(mi,c);
    sum+=c;
  }
  cout << (sum-ma-mi)/(num-2) << endl;
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int roop=1;
  while(roop--)
    solve();
  return 0;
}

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

using  namespace std;
int n;
void solve(){
  int inputMin=10001, inputMax=-1;
  int score,ans = 0;
  for(int input = 0; input < n ; input ++){
    cin >> score;
    ans += score;
    inputMin = min(inputMin , score);
    inputMax = max(inputMax , score);
  }
  ans = (ans - inputMin -inputMax)/ (n-2);
  cout << ans << endl;
}
int main(){

  while(cin >> n){
    if(n == 0) break;
    solve();
  }


  return 0;
}