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())
		if n == 0 {
			break
		}
		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 < len(scores)-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define INF 10000000000000000
#define MOD 998244353
using namespace std;

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

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

int main(void) {
	int N;
	while (cin >> N, N) {
		vector<int> score(N);
		for (int i = 0; i < N; i++)
			cin >> score[i];
		sort(score.begin(), score.end());
		
		int sum = 0;
		for (vector<int>::iterator it = score.begin() + 1; it != score.end() - 1; it++)
			sum += *it;
		int avg = sum / (N - 2);

		cout << avg << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int i,N,total=0,maxdayo,mindayo,box[1000];
  while(1){
  cin>>N;
  if(N==0) break;
  else{
  for(i=0;i<N;i++){
    cin>>box[i];
  }
  maxdayo=0;
  mindayo=1000;
  for(i=0;i<N;i++){
    total+=box[i];
    maxdayo=max(box[i],maxdayo);
    mindayo=min(box[i],mindayo);
  }
  total=total-maxdayo-mindayo;
  cout<<total/(N-2)<<endl;
  }
  total=0;
  }
  return 0;
}

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

int N, S;

int main()
{
   while ( cin >> N && N>0)
   {
      int M, m, addup, i;
      M = -1;
      m = 1001;
      addup = 0;
      for ( i = 0; i<N; i++)
      {
         cin >> S;
         addup += S;
         if ( S > M) M = S;
         if ( S < m) m = S;
      }
   cout << (addup - M - m)/(N-2)  << endl;
   }
}

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

int comp(const void* a, const void* b) {
	return (*(int*)a - *(int*)b);
}

int main() {
	int n;
	while (1) {
		cin >> n;
		if (n == 0) break;
		int points[n];
		for (int i = 0; i < n; i++) {
			cin >> points[i];
		}
		qsort(points, n, sizeof(int), comp);
		int sum = 0;
		for (int i = 1; i < n - 1; i++) {
			sum += points[i];
		}
		cout << sum / (n - 2) << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int n,s[120],count;;
	while(true){
		cin>>n;
		count=0;
		for(int i=0;i<n;i++){
			cin>>s[i];
			count+=s[i];
		}
		for(int i=0;i<n-1;i++){
			for(int j=n-1;j>i;j--){
				if(s[j]<s[j-1]){
					int tmp=s[j];
					s[j]=s[j-1];
					s[j-1]=tmp;
				}
			}
		}
		count-=s[0];
		count-=s[n-1];
		cout<<count/(n-2)<<endl;
	}
    return 0;
}

C++: #include<iostream>
#include<algorithm>
 
using namespace std;
 
int main(){
    while( true ){
        int n;
        cin >> n;

        if (n == 0) break;

        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;

    }   
    return 0; 
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> p;
#define le 1000000007;
int main(){
  while(1==1){
  int n;
  cin >> n;
  if(n==0)break;
  long long int sum=0;
  vector<int> v(n,0);
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  for(int i=1;i<n-1;i++){
    sum+=v[i];
  }
  cout << sum/(n-2) << endl;
  }
  return 0;
}

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

int main() {
	int N;
	while (cin >> N) {
		if (N == 0) break;
		int A, COUNT = 0, MAX = 0, MIN = 10000;
		for (int i = 0; i < N; i++) {
			cin >> A;
			COUNT += A;
			MAX = max(MAX, A);
			MIN = min(MIN, A);
		}
		cout << (COUNT - MAX - MIN) / (N - 2) << endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
const int MAX_N=101;

int n,ans;
vector<int> s(MAX_N);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n,n){
        for (int i=0;i<n;++i) cin >> s[i];
        sort(s.begin(),s.begin()+n);
        ans=0;
        for (int i=1;i<n-1;++i) ans+=s[i];
        cout << ans/(n-2) << '\n';
    }
}

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

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; // Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int>>
    IntReversePrioQueue; // A->Z

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

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

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

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

using namespace std;

int main(){
     int N;
     while(cin>>N,N){
	  multiset<int> ten;
	  for(int i=0;i<N;i++){
	       int temp;
	       cin>>temp;
	       ten.insert(temp);
	  }
	  multiset<int>::iterator itr=ten.begin();
	  ten.erase(itr);
	  multiset<int>::reverse_iterator ritr=ten.rbegin();
	  ritr++;
	  ten.erase(ritr.base());
	  itr=ten.begin();
	  int sum=0;
	  while(itr!=ten.end()){
	       sum+=*itr;
	       itr++;
	  }
	  cout<<(int)sum/ten.size()<<endl;
     }
}

C++: #include <cstdio>

using namespace std;

int main(){
  int min,max,sum,n,score;

  while(1){
    scanf=0("%d",&n);
    if(!n) break;

    max=0;min=10000;sum=0;

    for(int i=0;i<n;i++){
        scanf("%d",&score);
        if(max<score) max=score;
        if(min>score) min=score;
        sum+=score;
    }

    printf("%d\n",(score-max-min)/(n-2));
}
    return 0;
}

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

using namespace std;

int main(void){

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

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

int main(){
  int n,s[100],num,max=s[0],min=s[0];
  
  while(n != 0){
  cin>>n;    
    num=0;
    
  for(int i=0;i<n;i++){
    cin>>s[i];

    if(max<s[i])max=s[i];
    if(max>s[i])min=s[i];
       
    num += s[i];
  }
  num = (num-max-min)/n;
    cout<<num<<endl;

  }
  return 0;
}