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 <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <cstdio>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;(i)>=0;(i)--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;

vector<string> M;

int main(){

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

C++: #include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}
int main(){
  ll N;
  cin>>N;
  ll T[N];
  ll sum=0;
  for(ll i=0; i<N; ++i){
    cin>>T[i];
  }
  sort(T,T+N);
  for(ll i=1; i<N-1; ++i){
  	sum+=T[i];
  }
  cout<<sum/(N-2)<<endl;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int main(){
    while(true){
        int n; cin >> n; if(n ==0 ) break;
        int sum = 0; int cou = 0;
        vi v(n,INF);
        rep(i,n){cin >> v[i];}
        rep(i,n) cout << v[i] << endl;
        sort(v.begin(),v.begin()+n);
        v.erase(v.begin());
        v.erase(v.end()-1);
        rep(i,n-2){
            sum+=v[i]; cou++;
        }
        cout << sum /cou << endl;
    }
}

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

using namespace std;

void solve(int n){
  list <int> s;
  for(int i = 0 ; i < n ; i++ ){
    int a;
    cin >> a;
    s.push_back(a);
  }
  
  int s_max = 0;
  int s_min = 0xFFFF;
  list<int>::iterator s_max_it;
  list<int>::iterator s_min_it;

  for(list<int>::iterator it = s.begin() ; it != s.end() ; it++ ){
    if(*it > s_max){
      s_max = *it;
      s_max_it = it;
    }
    if(*it < s_min){
      s_min = *it;
      s_min_it = it;
    }
  }
  
  s.erase(s_max_it);
  s.erase(s_min_it);

  int sum = 0;
  for(list<int>::iterator it = s.begin() ; it != s.end() ; it++ ){
    sum += *it;
  } 
  cout << sum / (n-2) << endl;
  return;
}

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

  }

  return 0;
}

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

int main(){
  int n,num[1000];
  while(1){
  cin >> n;
  if(!n)break; 
  for(int i = 0 ; i < n ; i++){
    cin >> num[i];
  }
  sort(num,num+n);
  int ans = 0;
  for(int i = 1 ; i < n-1 ; i++){
    ans += num[i];
  }
  cout << ans/(n-2) << endl;
  }
  return 0;
}

C++: #include <stdio.h>
int main()
{
    int n;
    while(1){
        cin >> n;
        if(n == 0) break;
        int max = -1, min = 10000, sum = 0, score = 0, ans = 0;
        for(int i = 0; i < n; i++){
            cin >> score;
            sum += score;
            if(score > max) max = score;
            if(score < min) min = score;
        }
        sum -= max + min;
        ans = sum / (n - 2);
        cout << ans << endl;
    }
    return 0;
}

C++: 
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <iomanip>
#include <functional>
using namespace std;
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

int main(int argc, char* argv[])
{
    int ninzu=0;
    while(cin >> ninzu){
        int ans=0;
        int i=0;
        int temp=0;
        int a=0;
        
        vector <int>  s;
        
        
        for(i=0;i<ninzu;i++){
            cin >> a;
            if(temp < a){
                temp = a;
            }
            s.push_back(a);
        }
        
        sort( ALL(s) );
        
        for(i=1;i<s.size()-1;i++){
            if(s[i] != temp || s[i] != 0)ans+= s[i];
        }
        
        ans = ans / (i-1);
        
        cout << ans << endl;
        ans=0;
    }
    
    return 0;
}

C++: #!/usr/bin/env ruby -
# coding: utf-8

while true do
    # ????°??????§???????????? (?????????0??\???1000??\???)
    max = -1
    min = 1001
    # ????¨?????????????
    sum = 0
    # n??????
    n = gets.to_i
    break if n == 0 # 0?????¨????????????
    # n?????????????????????
    n.times do
        v = gets.to_i
        min = v if v < min
        max = v if v > max
        sum += v
    end
    sum -= (min + max)
    p sum / (n-2)
end

C++: #include<iostream>

using namespace std;

int main(){
  int n,i,p,max,min,s;

    while(1){
      cin>> n;
      if(n){}else break;
      
      cin>> p;
      s = p;
      max = p;
      min = p;

      for(i = 0 ; i < n-1 ;i++){
          cin>> p;
          s += p;
          if(max < p){
              max = p;
	  }
          if(min > p){
              min = p;
	  }
      }
      s = (s - max - min)/ (n-2);
      cout<< s << endl;
  }    
  return 0;
}

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

int main() {
  int max = 0;
  int min = 1000;
  int sum = 0;
  int num = 0;
  int judge = 0;
  while (true) {
    sum = 0;
    cin >> num;
    judge = num;
    if (num == 0) break;
    for (int i = 0; i < judge; i++) {
      cin >> num;
      if (max < num) max = num;
      if (min > num) min = num;
      sum += num;
    }
    int result = (sum - max - min) / (judge - 2);
    cout << result << endl;
  }
  return 0;
}

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

using namespace std;

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