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;

template<class T>
bool chmax(T& a, const T& b) {
    if (a < b) { a = b; return true; }
    return false;
}
template<class T>
bool chmin(T& a, const T& b) {
    if (b < a) { a = b; return true; }
    return false;
}

// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

// std::vector Declaration and Initialization
template<typename T>
vector<T> make_vector(size_t a, T x) { return vector<T>(a, x); }
template<typename T, typename U, typename... Ts>
auto make_vector(size_t a, U b, Ts... ts) {
    return vector<decltype(make_vector<T>(b,ts...))>(a, make_vector<T>(b, ts...));
}

// std::vector Input
template<typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto &e : v) is >> e;
    return is;
}

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::array Debug
template<typename T, size_t n>
ostream& operator<<(ostream& os, const array<T, n>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::deque Debug
template<typename T>
ostream& operator<<(ostream& os, const deque<T>& d) {
    os << "[";
    bool a = 1;
    for (auto e : d) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << " " << p.second << ")";
    return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
    os << "{";
    bool a = 1;
    for (auto e : mp) {
        os << (a ? "" : " ");
        os << e.first << ":" << e.second;
        a = 0;
    }
    os << "}";
    return os;
}

// std::tuple Debug
template<int N, class Tuple>
void out(ostream& os, const Tuple& t){}
template<int N, class Tuple, class H, class ...Ts>
void out(ostream& os, const Tuple& t) {
    if (N) os << " ";
    os << get<N>(t);
    out<N+1,Tuple,Ts...>(os, t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
    os << "(";
    out<0,tuple<Ts...>,Ts...>(os, t);
    os << ")";
    return os;
}

// Debug
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl

// Weighted edge
template<typename T>
struct edge {
    int src, to;
    T cost;

    edge() {}
    edge(int to, T cost) : src(-1), to(to), cost(cost) {}
    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    friend ostream& operator<<(ostream& os, const edge& e) {
        return os << "(" << e.src << "->" << e.to << ":" << e.cost << ")";
    }
};

using LL = long long;

#define fs first
#define sc second

const LL MOD = 1e9+7;


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

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

        int sum = 0, ma = 0, mi = 1000;

        for (int i = 0; i < n; ++i) {
            int x; cin >> x;
            sum += x;
            chmax(ma, x);
            chmin(mi, x);
        }

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

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){for(int m,n,t;cin>>n,n;){int a[n];for(m=n;t=m--;)cin>>a[m];sort(a,a+n);for(m=n-1;--m;)t+=a[m];cout<<t/(n-2)<<endl;}return 0;}

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

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

C++: #include <stdio.h>
int main()
{
  int n;
  while(scanf("%d", &n),n){
    int max=0,min=1000,s;
    long sum=0;
    for(int i=0; i<n; i++){
      scanf("%d",&s);
      sum+=s;
      max=max<s ? s : max;
      min=s<min ? s : min;
    }
    printf("%ld\n", (sum-min-max)/(n-2));
  }
}

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,score+5,0);
    cout << sum/(n-2) <<endl;
  }
  return 0;
}

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

int main(){
	int n,sum,t;
	deque<int> deq;
	while(cin >> n , n){
		deq.clear();
		for(int i=0;i<n;i++){
			cin >> t;
			deq.push_back(t);
		}
		
		sort(deq.begin(),deq.end());
		
		deq.pop_back();
		deq.pop_front();
		sum = 0;
		for(int i=0;i<deq.size();i++){
			sum += deq[i];
		}
		cout << sum / deq.size() << endl;
	}
}

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

int main(void) {
    int max,min,num,average,avsum;
    do{
        cin>>num;
        int rawdata[1000] = {0};
        if(num == 0){
            return 0;
        }
        max = 0,min = 1000,avsum = num,average = 0;
        while(num > 0){
            num--;
            cin>>rawdata[num];
        }
        for(int i = 0; i < avsum;i++) {
            average += rawdata[i];
            if(max < rawdata[i]){
                max = rawdata[i];}
            if(min > rawdata[i]){
                min = rawdata[i];}
        }
        
        average -= max;
        average -= min;
        
        average /= (avsum - 2);
        cout<<average<<endl;
    }while(1);
    return 0;
}

C++: #include <iostream>

int main(){
  int N;
  while(std::cin>>N&&N>0){
    int sum=0,max=-1,min=1001;
    for(int i=0;i<N;++i){
      int s;
      std::cin>>s;
      sum += s;
      max = std::max(s,max);
      min = std::min(s,min);
    }
    std::cout<<(sum-max-min)/(N-2)<<std::endl;
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a[101],sum,n;
	while(cin>>n,n){
	sum=0;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<n;i++)if(i!=0&&i!=n-1)sum+=a[i];
	cout<<sum/(n-2)<<endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int N, A[1024],Max,Min,Sum;

int main(){
 while(cin >> N && N>0){
  for (int i=0; i<N; ++i)
    cin >> A[i];
  for (int j=0; j<(N-1); ++j){
    Max=A[0];
	if(A[j+1]>A[j]) Max=A[j+1];
    }
  for (int k=0; k<(N-1); ++k){
    Min=A[0];
	if(A[k+1]<A[k]) Min=A[k+1];
	}
  for (int l=0; l<N; ++l){
    Sum += A[l];
	}
  cout<< (Sum-Max-Min)/(N-2) << endl;
 }
}