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

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

int main(void){
	int T;
	while(cin >> T, T){
		vector<int> in;
		int a;
		for(int i = 0; i < T; i++){
			cin >> a;
			in.push_back(a);
		}
		sort(in.begin(), in.end());
		int ans = 0;
		for(int i = 1; i < in.size()-1; i++){
			ans += in[i];
		}
		cout << (int)(ans / (in.size()-2)) << endl;
	}
	
	return 0;
}

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

int N, S;
int main() {
  while (cin >> N && N > 0) {
    int sum = 0, max = 0, min = 1000;
    for (int i = 0; i < N; i++) {
      cin >> S;
      sum += S;
      if (S > max) max = S;
      if (S < min) min = S;
    }
    cout << (int)((sum-max-min)/(N-2)) << endl;
  }
}

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

int main() {
	int n;
	while (std::cin >> n && n) {
		std::vector<int> p;

		for (int i = 0; i < n; i++) {
			int a; std::cin >> a;
			p.push_back(a);
		}

		std::sort(p.begin(), p.end());

		int sum = 0;
		for (int i = 1; i < p.size() - 1; i++) {
			sum += p[i];
		}

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

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

int main()
{
    int a,b[100];
    cin>>a;
    int max=0,min=1000,sum=0,result=0;
    for(int i=0;i<a;i++){
        cin>>b[i];
        sum+=b[i];
        if(b[i]<min){
            min=b[i];
        }
        if(b[i]>max){
            max=b[i];
        }
    }
    result=sum-min-max;
    cout<<result/(a-2)<<endl;
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <stack>

#define rep(i,x) for(int i=0;i<x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rep_to(a,i,x) for(int i=a;i<x;i++)

using namespace std;

int kai(int n)
{
	int sum=1;
	for(int i=n;i>=1;i--)sum*=i;
	return sum;
}

int main()
{
	int n;
	while(1){
	cin>>n;
	if(n==0)break;

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