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 <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
  int n;
  int point[100], average;
  
  while(1){
    average = 0;
    cin >> n;
    if(n == 0) break;

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

C++: #include <stdio.h>
 
int main(){
    int n,s[1024]={0};
        int max,min,max1,min1;
        int sum,i;
 
scanf("%d\n",&n);
 
do {
        max=0;
        min=100000;
        sum=0;
        sum=0;
    max1=0;
    min1=0;
        for (i=0;i<n;i++){
                scanf("%d\n",&s[i]);
                if(s[i]>max){
            max=s[i];
                        max1=i;
                }
                if(s[i]<min){
                        min=s[i];
            min1=i;
                }
        }
        for(i=0;i<n;i++){
                if(i!=max1&&i!=min1){
                        sum+=s[i];
                }
        }
        printf("%d\n",sum/(n-2));
        scanf("%d\n",&n);
}while (n!=0);
return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  while (true) {
    int n; cin >> n;
    if (n == 0) break;
    V<> a(n); for (int i = 0; i < n; ++i) cin >> a[i];
    sort(begin(a), end(a));
    int res = accumulate(next(begin(a)), prev(end(a)), 0) / (n - 2);
    cout << res << '\n';
  }
}

C++: gag

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

int main() {
        int i, j;
        int n;
        while (cin >> n) {
                if (n == 0) break;
                int sum = 0;
                vector<int> a(n);
                for (i = 0; i < n; i ++) {
                        cin >> a[i];
                        sum += a[i];
                }
                sort(a.begin(), a.end());
                sum -= a.front();
                sum -= a.back();
                cout << sum / (n - 2) << endl;
        }
        return 0;
}

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

int main(){
    while(1){
        int N;
        cin >> N;
        if(N==0)
            break;
        int s[111];
        for (int i = 0; i < N; i++)
            cin >> s[i];
        int M=-1, m=1111, sum = 0; // M:最大値, m:最小値
        for (int i = 0; i < N;i++){
            M = max(M, s[i]);
            m = min(m, s[i]);
            sum += s[i];
        }
        int ans = (sum - M - m) / (N - 2);
        cout << ans << endl;
    }
}

C++: #include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    while(N){
        int sum = 0,a,maxi = 0,mini = INF;
        rep(i,0,N){
            cin >> a;
            sum += a;
            maxi = max(maxi, a);
            mini = min(mini, a);
        }
        sum -= (maxi + mini);
        cout << sum / N << endl;
        cin >> N;
    }
}

C++: #include<stdio.h>

int main(){

int n;
int P[102]={};
while(1){
scasnf("%d",&n);if(n==0)break;
for(int i=0;i<n;i++)
scanf("%d",&P[i]);

int s=0;
for(int i=0;i<n;i++)
for(int j=n-1;j>i;j--)
if(P[j]>P[j-1]){int t=P[j];P[j]=P[j-1];P[j-1]=t;}

for(int i=0;i<n;i++)
if(i!=0&&i!=n-1)s+=P[i];

s=s/n;
printf("%d\n",s);
}
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;
    }   
 
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <iomanip>
#include <functional>
using namespace std;
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

int main(int argc, char* argv[])
{
	

	while(1){
		int ans=0;
		int i=0;
		int temp=0;
		int a=0;
		int ninzu=0;
		vector <int>  s;

		cin >> ninzu;

		for(i=0;i<ninzu;i++){
			cin >> a;
			if(temp < a){
				temp = a;
			}
			s.push_back(a);
			if(a == 0)break;
		}
		sort( ALL(s) );

		for(i=1;i<s.size()-1;i++){
			if(s[i] != temp || s[i] != 0)ans+= s[i];
		}

		ans = ans / (i-1);

		cout << ans << endl;
		ans=0;

	}

    return 0;
}

C++: #include <iostream>
using namespace std;
int N, A[1024],Max,Min,Sum;

int main(){
 while(cin >> N && N>0){
  for (int i=0; i<N; ++i)
    cin >> A[i];
  for (int j=0; j<N; ++j){
    Max=A[0];
	if(A[j]>Max) Max=A[j];
    }
  for (int k=0; k<N; ++k){
    Min=A[0];
	if(A[k]<Min) Min=A[k];
	}
  for (int l=0; l<N; ++l){
    Sum += A[l];
	}
  cout<< (Sum-Max-Min)/(N-2) << endl;
  Sum=0;
  Max=0;
  Min=0;
 }
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/

int n;
string s[155];
bool up=false;

void init(){
  rep(i,105)s[i]="aaa";
}

int main(){
  int n;
  int data[105];
  while(cin>>n){
    if(n==0)break;
    rep(i,n)cin>>data[i];
    sort(data,data+n);
    ll sum=0;
    for(int i=1;i<n-1;i++)sum+=data[i];
    cout<<sum/(n-2)<<endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;

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

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