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;

int main()
{
  while(1)
    {
      int n = 0,mx=-1,mn=1001;
      cin >> n;
      if(n==0)break;
      int avr = 0;
      for(int i=0;i<n;i++)
	{
	  int b;
	  cin >> b;
	  mx =max(b,mx);
	  mn =min(b,mn);
	  avr +=b;
	}
      cout << (avr - mx -mn) /(n -2) << endl;
    }
    


  return 0;
}

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

}

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

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

C++: #include<algorithm>
#include<iostream>
#define rep(i,a) for(int i=0;i<(a);++i)

int n;

int main()
{
	while( std::cin >> n, n )
	{
		int ma = 0, mi = 1001, S = 0;
	
		rep( i, n )
		{
			int a;
			std::cin >> a;
			ma = std::max( ma, a );
			mi = std::min( mi, a );
			S += a;		
		}
		
		std::cout << (S-ma-mi)/(n-2) << std::endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
#define ll long long
#define INF 1000000000
using namespace std;
int main(){
    int N;
    int s;
    int smax,smin;
    int sum;
    while(1){
        cin >> N;
        if(N==0) return 0;
        smax = 0; smin = INF; sum = 0;
        for(int i=0;i<N;i++){
            cin >> s;
            smax = max(smax,s);
            smin = min(smin,s);
            sum += s;
        }
        sum = sum - smax - smin;
        int ans = sum/(N-2);
        cout << ans << endl;
    }
}

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

int main() {
    int N;
    while (cin >> N, N) {
        vector<int> v(N);
        for (auto& i : v) cin >> i;
        sort(v.begin(), v.end());

        int sum = 0;
        for (int i = 1; i < N-1; i++) {
            sum += v[i];
        }

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

    return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <random>


// boost
#define USE_BOOST_IN_CODE
#ifdef USE_BOOST_IN_CODE
#include <boost/range.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/strided.hpp>
#include <boost/range/adaptor/transformed.hpp>
#include <boost/format.hpp>
#endif


using ll = long long;

//vector
template <class T>
using vec = std::vector<T>;

//namespace std
//{
//    template<>
//    class hash<Key>
//    {
//    public:
//        size_t operator() (const Key& key) const
//        {
//            size_t seed = 0;
//            auto i_hash = hash<int>()(key.i_th);
//            auto w_hash = hash<int>()(key.W);
//
//            seed ^= i_hash + 0x9e3779b9 + (seed << 6) + (seed >> 2);
//            seed ^= w_hash + 0x9e3779b9 + (seed << 6) + (seed >> 2);
//
//            return seed;
//        }
//    };
//}

void solve()
{
    using namespace std;

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

        vec<int> v(n);
        for (auto& x : v)
            cin >> x;

        boost::sort(v);

        cout << accumulate(v.cbegin() + 1, v.cend() - 1, 0) / (n - 2) << endl;
        ++count;
    }

}

int main()
{
    solve();
    return 0;
}

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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define reps(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) reps(i, 0, n)
#define REPS(i, a, b) reps(i, a, b)
#define REP(i, n) rep(i, n)
#define deps(i, a, b) for (int i = a; i >= b; --i)
#define dep(i, n) deps(i, n, 0)
#define DEPS(i, a, b) deps(i, a, b)
#define DEP(i, n) dep(i, n)

#define pf push_front
#define pb push_back
#define mp make_pair
#define fst first
#define FST fst
#define sec second
#define SEC sec
#define sz(obj) ((int)(obj).size())
#define all(v) (v).begin(), (v).end()
#define ALL(v) all(v)

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T> void print(T x) { std::cout << x << '\n'; }

signed main()
{
  while (int n = in(), n){
    vi v;
    int sum = 0;

    rep(i, n) v.pb(in());
    sort(all(v));
    for (int i = 1; i < n - 1; i++) sum += v[i];
    print(sum / (n - 2));
  }

  return (0);
}

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

int main(){
    int n;

    while(true){
        std::cin >> n;
        if(n == 0) break;

        int* x = new int[n];

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

        std::sort(x, x+n);
        int sum = 0;
        for(int i=1; i<(n-1); i++){
            sum += x[i];
        }

        std::cout << sum/(n-2) << std::endl;

        delete[] x;
    }

    return 0;
}

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

using namespace std;

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

}

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

C++: #include <iostream>

int main() {
	while (true) {
		int referee;
		std::cin >> referee;
		if (referee == 0) {
			break;
		}

		int max, min;
		std::cin >> max >> min;
		if (max < min) {
			std::swap(min, max);
		}
		int total = 0;
		for (int i = 2; i < referee; ++i) {
			int score;
			std::cin >> score;
			if (max < score) {
				total += max;
				max = score;
			} else if (min > score) {
				total += min;
				min = score;
			} else {
				total += score;
			}
		}
		std::cout << (total / (referee - 2)) << std::endl;
	}
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n;
    while(1){
        cin>>n;
        if(n==0)break;
        vector<int> s(n);
        for(int i=0;i<n;i++){
            cin>>s[i];
        }
        sort(s.begin(),s.end());
        long long ans=0;
        for(int i=1;i<n-1;i++){
            ans+=s[i];
        }
        cout<<ans/(n-2)<<endl;
    }
    return 0;
}