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))
	}
}

Python: from statistics import mean
while True:
  N = int(input())
  if N == 0:
    break
  S = []
  for i in range(N):
    S.append(int(input()))
  S.remove(max(S))
  S.remove(min(S))
  print(int(mean(S)))

Python: while True:
    N = int(input())
    if N == 0:
        break
    S = []
    for i in range(N):
        S.append(int(input()))
    print((sum(S)-max(S)-min(S))//(N-2))

Python: while True:
    n=int(input())
    if n==0:
        break
    s=[int(input()) for i in range(n)]
    a=max(s)
    b=min(s)
    c=sum(s)
    d=(c-a-b)//(n-2)
    print(d)

Python: import math

def main():
    r = []
    while True:
        n = int(input())
        if n == 0:
            break
        m = []
        for i in range(n):
            m.append(int(input()))
        r.append(math.floor((sum(m) - max(m) - min(m)/(n-2))))
    res = ''
    for j in r:
        res += str(j)
    print(res)

main()

Python: n=int(input())
while n!=0:
    total=0
    saidai=None
    saishou=None
    for i in range(n):
        s=int(input())
        total+=s
        if saidai is None or s>saidai:
            saidai=s
        if saishou is None or s<saishou:
            saishou=s
    print((total-saidai-saishou)//(n-2))        
    n=int(input())

Python: from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

while True:
    n = inp()
    if n == 0:
        break
    else:
        aa = [inp() for i in range(n)]
        aa.sort()
        print(sum(aa[1:n-1])//(n-2))

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

int main(){
  int flag = 1;
  int n,x;
  cin >> n;
  if(n==0) return 0;
  while(flag){
    int max = -1;
    int min = 1001;
    int sum = 0;
    for(int i=0;i<n;i++){
      cin >> x;
      if(x > max){
        sum += max;
        max = x;
      }else if(x < min){
        sum += min;
        min = x;
      }else sum += x;
    }
    sum -= 1000;
    sum = sum / (n - 2);
    cout << sum << endl;
    cin >> n;
    if(n == 0) flag = 0;
  }
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){

  int n,s,ans;
  vector<int> list;
  while(1){
    cin >>n;
    list.resize(n);
    if(n==0)return 0;
    rep(i,n)
      cin>>list[i];
    sort(list.begin(),list.end());
    ans=0;
    for(int i=1;i<n-1;i++)
      ans+=list[i];
    ans/=n-2;
    cout<<ans<<endl;
  }
  return 0;
}

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

using namespace std;

int main() {
    int n;
    while (cin >> n && n) {
        vector<int> vi;
        for (int i = 0; i < n; i++) {
            int a;
            cin >> a;
            vi.push_back(a);
        }

        sort(vi.begin(), vi.end());

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

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

C++: #include<iostream>
 
using namespace std;
 
int main(){
    while( true ){
        int n;
        int ma = 0;
        int mi = 1000;
        int s = 0;
        cin >> n;

        if(n == 0){
            break;
        }

        int a[n];

        for(int i=0;i<n;i++){
            cin >> a[i];
            if(ma < a[i]){
                ma = a[i];
            }
            if(mi > a[i]){
                mi = a[i];
            }
            s += a[i];
        }

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

C++: #include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    while(scanf("%d",&n),n!=0) {
        int sum=0,max_s=0,min_s=1000;
        for(int i=0;i<n;i++) {
            int s;
            scanf("%d",&s);
            max_s=max(max_s,s);
            min_s=min(min_s,s);
            sum+=s;
        }
        printf("%d\n",(sum-max_s-min_s)/(n-2));
    }
}

C++: #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

#define Rep(b, e, i) for (int i = b; i <= e; i++)
#define Repr(e, b, i) for (int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n - 1, i)
#define repr(n, i) Repr(n - 1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)), (x).end())

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1 <<29;
const int MOD = 1000000007;

void solve(void) {
  while (1) {
    int N;
    scanf("%d\n", &N);
    if (N == 0) break;
    vector<int> ps;
    int ans = 0;
    rep(N, i) {
      int p;
      scanf("%d\n", &p);
      ps.pb(p);
      ans += p;
    }
    sort(all(ps));
    ans -= ps[0] + ps[N-1];
    printf("%d\n", ans / (N-2));
  }
}

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

C++: #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
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;
}
///////////////////////////////////////////////////////////////

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); //入出力高速化
  while (true) {
    int N; cin >> N;
    if (N == 0) break;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    sort(all(A));
    ll sum = accumulate(A.begin()+1,A.end()-1,0);
    cout << sum / (N-2) << endl;
  }
}

C++: 
#include <cstdio>

int main(){
   int n;

   while(true){
        scanf("%d",&n);
        if(n == 0){
            break;
        }
        int min = 1000;
        int max = 0;
        int sum = 0;
        for(int i = 0;i < n;i++){
            int k;
            scanf("%d",&k);
            if(k <= min){
                min = k;
            }
            if(k >= max){
                max = k;
            }
            sum += k;
        }
        printf("%d\n",(sum - (max + min)) / (n - 2));
    };
}

C++: #include<iostream>
#include<math.h>
using namespace std;
int main() {
	int kazu, score, q = 0, sum = 0, ave;
	//審査員の数を入れる
	while (cin >> kazu) {
		if (kazu == 0)break;
		int *point = new int[kazu];
		while (cin >> score) {
			for (int w = 0; w < q; w++) {
				if (point[w] < score)
					swap(point[w], score);
			}
			point[q] = score;
			q++;
			if (q == kazu)break;
		}
		for (int w = 1; w < q-1; w++) {
			sum += point[w];
		}
		sum /= q-2;
		cout << sum << endl;
		sum = 0; q = 0;
	}
	return 0;
}

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

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

		if (n == 0) {
			break;
		}

		int sum = 0;
		int max = 0;
		int min = 1000;
		for (int i = 0; i < n; i++) {
			int s;
			cin >> s;

			sum += s;
			if (s > max) {
				max = s;
			}
			if (s < min) {
				min = s;
			}
		}

		cout << (sum - max - min) / (n - 2) << endl;
	}

	return 0;
}