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;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int n;
    while(cin>>n,n){
        int mx=0,mn=1001,s;
        int sum=0;
        rep(i,n){
            cin>>s;
            sum+=s;
            mx=max(mx,s),mn=min(mn,s);
        }
        cout<<(sum-mx-mn)/(n-2)<<endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    int n;
    while(1){
        cin >> n;
        if(n == 0){
            return 0;
        }
        int s_max = 0;
        int s_min = 1000;
        int sum = 0;
        int s;
        for( int i = 0; i < n ; ++i) {
            cin >> s;
            sum += s;
            s_max = max(s, s_max);
            s_min = min(s, s_min);
        }
        int ave = (sum-s_max-s_min)/(n-2);
        cout << ave << endl;
    }
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

#define PREP(i, m, n) for(int i = m; i < n; i++)
#define MREP(i, m, n) for(int i = m - 1; i >= n; i--)

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define prime first
#define weight second
#define MP make_pair
#define PB push_back

using namespace std;

int main(){
	int n = 0;
	while(cin >> n && n != 0){
		map<int, int> ev;
		int max = -1, min = 1001;
		
		rep(i, n){
			int s = 0;
			cin >> s;

			if(s > max) max = s;
			else if(s < min) min = s;

			if(ev.find(s) != ev.end()) ev[s]++;
			else ev[s] = 1;
		}

		ev[max]--;
		ev[min]--;

		double result = 0.0, factor = 0.0;
		
		for(map<int, int>::iterator it = ev.begin(); it != ev.end(); it++){
			rep(i, it->second){
				result += it->first;
				factor++;
			}
		}

		cout << (int)result / (int)factor << endl;
	}
	

	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <climits>
#include <cmath>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>

typedef long long          ll;
typedef unsigned int       uint;
typedef unsigned long long ull;

using namespace std;

int main() {
  while (true) {
    int n;
    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());
    std::cout << accumulate(s.begin() + 1, s.end() - 1, 0) / (s.size() - 2) << std::endl;
  }
}

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

int main(){
	int n, sum, x;
	while(cin >> n, n){
		vector<int> vec;
		for(int i = 0; i < n; i++){
			cin >> x;
			vec.push_back(x);
		}
		sort(vec.begin(), vec.end());

		sum = 0;
		for(vector<int>::iterator it = vec.begin() + 1; it != vec.end() - 1; it++){
			sum += *it;
		}
		cout << sum / (vec.size() - 2) << endl;
	}
}

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

using namespace std;

int main() {
  int n, input;

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

    vector<int> scores;
    for (int i = 0; i < n; i++) {
      cin >> input;
      scores.push_back(input);
    }

    cout << (accumulate(scores.begin(), scores.end(), 0) - *max_element(scores.begin(), scores.end()) - *min_element(scores.begin(), scores.end())) / (n - 2) << endl;
  }

  return 0;
}

C++: aaa

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

int s[100];

int main(){
	int n;
	while(scanf("%d", &n),n){
		for(int i = 0; i < n; i++) scanf("%d", &s[i]);
		sort(s,s+n);
		int sum = 0;
		for(int i = 1; i < n-1; i++){
			sum += s[i];
		}
		printf("%d\n", sum/(n-2));
	}
}

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

int main()
{
	int N, n, sum, largest, smallest;
	sum  = 0; largest = 0; smallest = 1000;
	
	cin >> N;
	
	for(int i = 0; i<N; i++)
	{
		cin >> n;
		sum += n;
		
		if(smallest > n){ smallest = n;}
		if(largest < n){ largest = n;}
	}
	
	cout << (sum-smallest-largest)/(N-2) << endl;
}