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 <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef vector<int>    VI;
typedef vector<bool>   VB;
typedef vector<string> VS;

#define MP make_pair
#define PB push_back
#define ALL(x)  (x).begin(),(x).end()
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int n;
VI ss;

int main(void) {
	while (1) {
		ss.clear();
		cin >> n;
		if (n == 0) break;
		rep (i, n) {
			int s;
			cin >> s;
			ss.PB(s);
		}
		sort(ALL(ss));
		int sum = 0;
		REP (i, 1, ss.size() - 1) {
			sum += ss[i];
		}
		cout << sum / (n - 2) << endl;
	}
    return 0;
}

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

using namespace std;
int main(){
  int n;
  int s[111];
  while(cin>>n){
    if(n ==0)
      break;
    for(int i = 0;i<n;i++){
      cin>>s[i];
    }
    sort(s,s+n);
    int ans = 0;
    for(int i = 1;i<n-1;i++)
      ans += s[i];

    ans /= n-2;
    cout<<ans<<endl;
  }
  return 0;


}

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;
          pre += p;
          if(max < p){
              max = p;
	  }
          if(min > p){
              min = p;
	  }
      }
      p = (p - max - min)/ (n-2);
      cout>> p >> endl;
  }    
  return 0;
}

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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
template<class T> using vv=vector<vector<T> >;

int main() {
  vector<int> results;

  while (true) {
    int count;
    cin >> count;
    if (count == 0) { break; }
    vi point(count);
    for (int i = 0 ; i < count ; i++) {
      cin >> point[i];
    }
    //sort(point.begin(), point.end());
    int max_point = -1;
    int min_point = 1001;
    int ave = 0;
    for (int i = 0 ; i <= point.size()-1 ; i++) {
      ave += point[i];
      if (max_point < point[i]) {
        max_point = point[i];
      }
      if (min_point > point[i]) {
        min_point = point[i];
      }
    }
    ave -= (max_point + min_point);
    ave /= (count-2);
    results.push_back(ave);
  }

  for (int i = 0 ; i < results.size() ; i++) {
    printf("%d\n", results[i]);
  }

  return 0;
}

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

int main(){
int n;
while(cin>>n){

if(n==0){break;}
int s[10000];
int al=0;
int mx=0;
int mi=10000;

for(int i=0;i<n;i++){
cin>>s[i];
al+=s[i];
mx=max(mx,s[i]);
mi=min(mi,s[i]);
}

al=(al-mx-mi)/(n-2);
cout<<al<<endl;
}



return 0;
}

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

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

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

using namespace std;

int main(){
	int size;
	while(true){
		cin >> size;
		if(size == 0){
			break;
		}
		int maxv=-1;
		int minv = 100000000;
		int sum = 0;
		for(int i=0;i<size;i++){
			int num;
			cin >> num;
			sum += num;
			minv = min(minv,num);
			maxv = max(maxv,num);
		}
		int result = (sum-minv-maxv)/(size-2);
		cout << result << endl;
	}
	return 0;
}