Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var (
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	for sc.Scan() {
		n, _ := strconv.Atoi(sc.Text())
		scores := make([]int, n, n)
		for i := 0; i < n; i++ {
			sc.Scan()
			scores[i], _ = strconv.Atoi(sc.Text())
		}
		sort.IntSlice(scores).Sort()
		var sum = 0
		for i := 1; i < n-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
//#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    for (int n; cin >> n && n;) {
        VI s(n); cin >> s;
        cout << (accumulate(all(s), 0) - *max_element(all(s)) - *min_element(all(s))) / (n - 2) << "\n";
    }
}

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

using namespace std;

int main(){

  

  int n;

  while(cin>>n){

    if(n==0){
      cout<<endl;
      break;
    }

  int a[n];

  int max,min;

  max=0;
  min=1000;

  for(int i=0;i<n;i++){

    cin>>a[i];

    if(a[i]>max){
      max=a[i];
    }

    if(a[i]<min){
      min=a[i];
    }

  }

  int sum;

  sum=0;

  for(int p=0;p<n;p++){

    sum=sum+a[p];

  }

  sum=sum-max-min;



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

  

  }




  return 0;
}

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

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

	return 0;
}

C++: #include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    while (1)
    {
        cin >> n;
        if (n == 0)
            break;
        vector<int> v(n);
        rep(i, n) cin >> v[i];
        sort(all(v));
        int sum = 0;
        for (int i = 1; i < n - 1; i++)
            sum += v[i];
        cout << sum / (n - 2) << endl;
    }
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n;
	while (cin >> n, n != 0) {
		vi s(n);
		int sum = 0;
		rep(i, 0, n) {
			cin >> s[i];
			sum += s[i];
		}
		sum -= *max_element(all(s)) + *min_element(all(s));
		cout << sum / (n - 2) << endl;
	}
}

C++: #include<stdio.h>
int main(void) {
	int n, s[100] = {0}, max, min,sum=0,count=0;
	scanf("%d", &n);
	for (int i = n; i > 0; i--) {
		scanf("%d", &s[i]);
		if (i == n) {
			max = s[i];
			min = s[i];
		}
		if (max < s[i]) max = s[i];
		if (min > s[i]) min = s[i];
		count++;
		if (s[i] == 0) break;
		sum += s[i];
	}
	sum = sum - (max + min);
	printf("%d", sum/(count-2));
	return 0;
}

C++: #include <iostream>

int main()
{

    while(1) {
        int judgeNum = 0;
        int pointSum = 0;
        int maximumPoint = 0;
        int minimumPoint = 1000;

        std::cin >> judgeNum;
        if (judgeNum == 0) {
            break;
        }

        int point[judgeNum];

        for(int i = 0; i < judgeNum; i++) {
            std::cin >> point[i];
            if(point[i] > maximumPoint) {
                maximumPoint = point[i];
            } else if (point[i] < minimumPoint) {
                minimumPoint = point[i];
            }
            pointSum += point[i];
        }

        int answerSum = pointSum - maximumPoint - minimumPoint;

        std::cout << answerSum / (judgeNum - 2) << std::endl;
    }
    return 0;
}

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

int main(void){
	int n;
	while(1){
		cin >> n;
		vector<int> data;
		if(n == 0) break;

		for(int i=0; i<n; i++){
			int x;
			cin >> x;
			data.push_back(x);
		}
		sort(data.begin(), data.end());
		long long sum = 0;
		for(int i=1; i<n-1; i++){
			sum += data[i];
		}
		sum /= n-2;
		cout << sum << endl;
	}


	return 0;
}

C++: #include <bits/stdc++.h>

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {
	int result[100] = {};
	int pos = 0;
	while (1) {
		int n;
		int s[101] = {};
		int mini = 1001;
		int maxi = -1;
		int total = 0;

		cin >> n;
		if (n == 0) {
			break;
		}
		pos++;
		FOR(i, 1, n) {
			cin >> s[i];
			if (maxi < s[i]) {
				maxi = s[i];
			}
			if (mini > s[i]) {
				mini = s[i];
			}
			total += s[i];
		}
		result[pos] = (total - maxi - mini) / (n - 2);
	}
	FOR(i, 1, pos) {
		cout << result[i] << endl << endl;
	}

}

C++: #include <iostream>

using namespace std;

int main(){
        int n, s ;
	while (cin >> n && n > 0){
		int large = 0;
		int small = 1000;
		int sum = 0;
  		for (int i=0; i>n; ++i){
			cin >> s;
			sum = sum + s;
			if (large < s) {large = s};
			if (small > s) {small = s};
		}
		int ans = 0;
		ans = (sum - large - small) / (n - 2);
		cout << ans << endl ;
	}
}