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 <climits>


int main(void){
  while(1){
    int n;
    std::vector<signed int> s;
    std::vector<signed int>::iterator it;

    std::cin >> n;
    if(n == 0) return 0;
    for(int i=0; i < n; i++){
      int inputting;
      std::cin >> inputting;
      s.push_back(inputting);
    }


    int max = -1, min = 1001;
    std::vector<int>::iterator maxind, minind;
    for(it = s.begin(); it != s.end(); it++){
      if(*it > max){
        max = *it;
        maxind = it;
      }
      if(*it < min){
        if(*it == 0)  min = 0;
        else{
        min = *it;
        minind = it;
        }
      }
    }

    s.erase(maxind);
    s.erase(minind);
    int sum = 0, avr;
    for(it = s.begin(); it != s.end(); it++){
      sum += *it;
    }
    std::cout << sum / s.size() << std::endl;
  }
}

C++: 
#include<cstdio>
#include<iostream>
#include<string>
#include <algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
using namespace std;
using ll = long long;



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

}

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

int main()
{
	int n,inp,sum;

	while(cin>>n,n!=0)
	{
		vector<int> score;
		for(int i=0;i<n;i++)
		{
			cin>>inp;
			score.push_back(inp);
		}

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

		sum=0;
		for(int i=1;i<n-1;i++)
			sum+=score[i];

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

C++: #include<bits/stdc++.h>
using namespace std;
typedef long long L;
L n;
int main(){
    while(scanf("%lld",&n)&&n){
        L ar[n+1],sum=0;
        for(L i=0;i<n;i++){
            scanf("%lld",&ar[i]);
        }
        sort(ar,ar+n);
        for(L i=1;i<n-1;i++)sum+=ar[i];
        cout<<sum/(n-2)<<"\n";
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
using mat = vector<vector<ll>>;

inline void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[5001][5002];



signed main(){
	IOS();
	ll n, sum, x;
	while(1){
		cin >> n;
		sum = 0;
		ll MAX = 0;
		ll MIN = 114514;
		if(n == 0)break;
		for (int i = 0;i < n;++i) {
			cin >> x;
			MAX = max(x, MAX);
			MIN = min(x, MIN);
			sum += x;
		}
		ll ans = floor((sum - MAX - MIN) / (double)(n - 2));
		cout << ans << endl;
	}

	return 0;
}

C++: #include <cstdio>
#include <vector>
using namespace std;
int main(){
    int n;
    for(;;){
        scanf("%d",&n);
        if(n==0) break;
        vector<int> ar(n);
        for(int &x : ar){
            scanf("%d",&x);
        }
        sort(ar.begin(),ar.end());
        int sum=0;
        for(int i=1;i<n-1;i++){
            sum+=ar[i];
        }
        printf("%d\n",sum/(n-2));
    }
}

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

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

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

int main(void) {
    int n;
    while (cin >> n, n) {
        vector<int> scores(n);
        for (int i = 0; i < n; i++) {
            cin >> scores[i];
        }
        sort(scores.begin(), scores.end());

        cout << accumulate(scores.begin()+1, scores.end()-1, 0) / (scores.size()-2) << endl;
    }

    return 0;
}

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

using namespace std;

int main(){

  int n;
  int max,min;
  int a;
  int sum;
  while(true){
    cin >>n;
    if(n==0)break;
    sum = 0;
    max = 0;
    min = 1001;
    for(int i=0;i<n;i++){
      cin >>a;

      if(a>max)max = a;
      if(a<min)min = a;
      sum+=a;
    }
    sum-=max+min;
    sum/=(n-2);
    cout <<sum<<endl;
  }


  return 0;
}

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

int main()
{
  int n;
  while(cin >> n, n){
    vector<int> s(n);
    for(int i = 0; i < n; i++) cin >> s[i];
    sort(s.begin(), s.end());

    int sum = 0;
    int i;
    for(i = 1; i < n - 1; i++) sum += s[i];
    cout << sum / (i - 1) << endl;
  }

    return 0;

}

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

using namespace std;

int main()
{
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        vector<int> score(n);
        for (int i = 0; i < n; i++) {
            cin >> score[i];
        }
        sort(score.begin(), score.end());

        int s = 0;
        for (int i = 1; i < n - 1; i++) {
            s += score[i];
        }
        cout << s / (n - 2) << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
using namespace std;

int main(){
  int N, i=1;
  cin >> N ;
  int v;
  vector<int> ans;
  while(N){
    vector<int> vec(N);
    for(int i = 1; i <= N;i++){
      cin >> v;
      vec[i-1] = v;
      if(i == N){
        sort(vec.begin(),vec.end());
        ans.push_back((int)(accumulate(vec.begin()+1,vec.end()-1,0)/(N-2)));
      }
    }
    cin >> N;
  }
  for(int i  =0 ; i < (int)ans.size();i++){
    cout << ans[i] << endl;
  }
}

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,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=0;i<s.size()-1;i++)
            ans+= s[i];
        
        ans = (ans- s[0]) / (i-1);
        
        cout << ans << endl;
        ans=0;
    }
    
    return 0;
}

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

int main(){
  int n, s, sum, max, min;
  while(1){
    cin >> n;
    if(n == 0) break;
    sum = 0;
    cin >> s;
    sum += s;
    max = s;
    min = s;
    cin >> s;
    sum += s;
    if(max < s){
      max = s;
    }else{
      min = s;
    }
    for(int i = 2; i < n; i++){
      cin >> s;
      sum += s;
      if(max < s){
	max = s;
      }else if(min > s){
	min = s;
      }
    }
    sum -= max;
    sum -= min;
    int ave = sum / (n-2);

    cout << ave << endl;
  }

  return 0;
}