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<vector>
#include<algorithm>

int main(){
	int n;
	while(std::cin >> n, n){
		std::vector<int> v;
		for(int i=0;i<n;i++){
			int j;
			std::cin >> j;
			v.push_back(j);
		}
		std::sort(v.begin(), v.end());
		int ave = 0;
		for(int i=1;i<v.size()-1;i++){
			ave += v[i];
		}
		ave /= n-2;
		std::cout << ave << std::endl;
	}
}

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

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    double h=-1,l=1<<30,sum=0;
    for(int i=0;i<n;i++){
      double s;
      cin>>s;
      sum+=s;
      h=max(s,h);
      l=min(s,l);
    }
    cout<<int((sum-h-l)/(n-2))<<endl;
  }
  return 0;
}

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

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

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

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int n;
  while(cin>>n){
    if(n==0) break;
    vector<int> a(n);
    REP(i,n)cin>>a[i];
    int s = accumulate(a.begin(),a.end(),0)- *min_element(a.begin(),a.end())
      - *max_element(a.begin(),a.end());
    cout<<s/(n-2)<<endl;
  }
  return 0;
}

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

using namespace std;

int main() {
	int a[20];
	int b,sum=0,point;
	while(1){
		cin >> b;
		if(b==0) break;
		for(int i=0;i<b;i++){
			cin >> a[i];
			
		}
		sort(a,a+b);
		for(int j=1;j<b-1;j++){
			sum+=a[j];
		}
		point=sum/(b-2);
		cout << point << endl;
		sum=0;
		
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int n;
int main(){
	while(cin>>n){
		if(n==0)break;
		int s[110]={},ma=0,mi=1001,cn=0;
		for(int i=0;i<n;i++){
			cin>>s[i];
			if(s[i]>ma){
				ma=s[i];
			}
			if(s[i]<mi){
				mi=s[i];
			}
			cn+=s[i];
		}
		cout<<((cn-mi)-ma)/(n-2)<<endl;
	}
	return 0;
}

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

int main() {
	int n;
	while (1) {
		cin >> n;
		if (n == 0) break;
		int sum = 0, maxP = 0, minP = 1000;
		for (int i = 0; i < n; i++) {
			int x;
			cin >> x;
			minP = min(minP, x);
			maxP = max(maxP, x);
			sum += x;
		}
		sum -= minP + maxP;
		cout << sum / (n - 2) << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main() {

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

C++: #include <iostream>
#include<stdio.h>
using namespace std;
int main(void){
    int n;
    int x[21];
    while(1){
        int S=0;

        cin>>n;
        if(n==0){
            break;
        }
        for(int i=0;i<n;i++){
            cin>>x[i];
        }
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(x[i] < x[j]){
                    int temp = x[i];
                    x[i] = x[j];
                    x[j] = temp;
                }
            }
        }
        for(int i=1;i<n-1;i++){
            S=S+x[i];
        }
        int A=0;
        A=S/(n-2);
        cout<<A<<endl;
    }
    return 0;
}

C++: #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const double pi=acos(-1);





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

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

C++: #include <iostream>

using namespace std;

int main(void){
  while(1){
    int n;
    cin >> n;
    if(n == 0){return 0;}

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

    int sum = 0;
    int max = -1;
    int min = 1001;
    for(int i = 0 ; i < n ; i++){
      if(max < point[i]){max = point[i];}
      if(min > point[i]){min = point[i];}

      sum += point[i];
    }

    cout << (int)(sum - max - min)/(n - 2);
  }

}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>

using namespace std;

int n;
int s;
vector<int> v;
int f;
int b;
int sum = 0;
int ans = 0;

int main() {

	while (cin >> n) {
		if (n == 0) break;
		for (int i = 0; i < n; i++) {
			cin >> s;
			v.push_back(s);
		}

		sort(v.begin(), v.end());

		f = v[0];
		b = v[v.size() - 1];

		for (int i = 0; i != v.size(); ++i) {
			sum += v[i];
		}
		sum = sum - f - b;
		ans = sum / (v.size() - 2);

		cout << ans << endl;

		v.clear();
		sum = 0;
		ans = 0;

	}
}

C++: #include<iostream>
using namespace std;
int main(){
int judge;
int maxscore =0;
int minscore =0;
int maxnum=0;
int minnum=0;
cin >> judge;
int score[judge];
	for(int i=0; i<judge; i++){
	cin >> score[i];
		if(score[i] > maxscore){
		maxscore = score[i];
		maxnum=i;
		}
		if(score[i] < minscore){
		minscore = score[i];
		minnum=i;
		}
		if(i==0){
		minscore = score[0];
		}
	}
score[maxnum] = 0;
score[minnum] = 0;
int lastscore = 0;
for(int j=0;j<judge;j++){
lastscore = lastscore +  score[j];
}
lastscore = lastscore/(judge - 2);
cout << lastscore <<endl;
return 0;
}

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

int main(){
        int i = 0;
        
        while(cin >> i && !(i == 0)){
                int a[i];
                int j = 0;              

                for(j=0; j<i; j++){
                        cin >> a[j];
                }
                cout << endl;           
        
                //sum
                int sum = 0;
                for (j=0; j<i; j++) {
                        sum += a[j];
                }
        
                //largest,smallest
                int largest = 0;
                int smallest = 1000;
                for (j=0; j<i; j++){
                        if (a[j] > largest)
                                largest = a[j];
                        else if (a[j] < smallest)
                                smallest = a[j];
                }
                
                //average
                int average = 0;
                average = (sum - largest - smallest) / (i - 2);
                cout << average;
        }
}