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>

using namespace std;

int main () {
  while (true){
    int n,i;
    int s = 0;
    int mi = 0;
    int ma = 0;
    cin >> n;

    if (n == 0)
      break;
??????
??????int point[n];

    for (i=0,i<n,i++){
      cin >> point[i];

      if (point[i] < mi)
        mi << point[i];

      if (point[i] > ma)
        ma << point[i];

      s += point[i];
    }

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

C++: #include <iostream>
using namespace std;
int N, S;
int main()
{
	/* code */
	while (cin >> N && N >0){
		int sum = 0;
		for(int i=0; i<N; i++){
			cin >> S;
			sum += S;
		}
		cout << sum << endl;
	}

}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <sstream>
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;

const int MAX_s = 1005;
int n, m, M, S, s;

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

        S = 0;
        m = MAX_s;
        M = 0;
        for(int i = 0; i < n; i++) {
            cin >> s;
            S += s;
            m = min(m, s);
            M = max(M, s);
        }

        cout << (int)((S - m - M) / (n - 2)) << endl;
    }

    return 0;
}

C++: #include <iostream>
using namespace std;
int N,S;
int main() {
 while (cin >> N && N>0) {
  int max = 0;
  int min = 1000;
  int sum = 0;
  int answer;
  for (int i=0; i<N; ++i) {
   cin >> S;
   sum += S;
   if(max < S) max = S;
   if(min > S) min = S;
  }
  answer = (int)((sum-max-min)/(N-2));
  cout << answer << endl;
 }
}

C++: #include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    
    /////////
    //write//
    /////////
    
    while (1){
        int n; cin >> n;
        if(n==0)break;
        int s[1000] = {0};
        for(int i=0; i<n; i++){
            cin >> s[i];
        }
        
        sort(s, s+n);
        
        int sum = 0;
        for(int i=1; i<n-1; i++){
            sum+=s[i];
        }
        sum/=(n-2);
        
        cout << sum << endl;
    }
    return 0;
}

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

int main(){
	int n;
	while (std::cin >> n && n){
		std::vector<int> score;
		for (int i = 0; i < n; ++i){
			int s;
			std::cin >> s;
			score.push_back(s);
		}
		std::sort(score.begin(), score.end());
		score.pop_back();
		score.erase(score.begin());
		int ans = 0;
		int cnt = 0;
		for (auto it = score.begin(); it != score.end(); ++it){
			ans += *it;
			cnt++;
		}
		std::cout << ans/cnt << std::endl;
	}
	return 0;
}

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 = INF,mini = 0;
        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 <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

int main() {
    int n;
    while (cin >> n, n) {
        vector<int> s(n);
        for (auto &si: s) cin >> si;
        sort(s.begin(), s.end());
        int sum = accumulate(s.begin(), s.end(), 0) - s.front() - s.back();
        cout << sum / (n - 2) << endl;
    }
    return 0;
}

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

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

}

C++: #include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>

#define BIT(a) (1 << (a))

using namespace std;

long long MOD = 1000000007;


long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

vector<int> v[30];
int ans[30];
int main(void){
	int N;
	int cnt = 0;
	while (1){
		cin >> N;
		if (N == 0) break;
		for (int i = 0; i < N; i++){
			int x;
			cin >> x;
			v[cnt].push_back(x);
		}
		cnt++;
	}
	for (int i = 0; i < cnt; i++){
		sort(v[i].begin(), v[i].end());
		for (int j = 0; j < v[i].size(); j++){
			if (j == 0 || j == v[i].size()-1) continue;
			ans[i] += v[i][j];
		}
		ans[i] /= v[i].size() - 2;
	}

	for (int i = 0; i < cnt; i++){
		cout << ans[i] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
using llong = long long;

llong n;
llong sum;
llong m;

int main() {

    while (scanf("%lld", &n), n != 0) {
        llong minv = 1ll << 60ll;
        llong maxv = -1;
        sum = 0;
        
        for (int i = 0; i < n; i++) {
            cin >> m;

            sum += m;

            minv = min(minv, m);
            maxv = max(maxv, m);
        }

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

    return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int n,s[120],count;;
	while(true){
		cin>>n;
		if(n==0)
			break;
		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>
using namespace std;

int main()
{
	int n,s[100],max,min,nmax,nmin,ret;
	while (cin >> n, n) {
		for(int i = 0;i < n;i++) {
			cin >> s[i];
		}
		min = 1000;
		max = 0;
		for (int i = 0; i < n; i++) {
			if (s[i] > max){
				max = s[i];
				nmax = i;
			}
			if (s[i] < min) {
				min = s[i];
				nmin = i;
			}
		}
		s[nmax] = s[nmin] = 0;
		ret = 0;
		for (int i = 0; i < n; i++) {
			ret += s[i];
		}
		cout << ret / (n - 2) << endl;
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <numeric>
#include <array>
#include <float.h>
#include <memory>
#include <functional>
#include <iomanip>
#include <queue>
#include <random>
#include <map>
#include <set>

#pragma warning(disable:4996)

using namespace std;

int main() {
  while (true) {
    int size;
    cin >> size;
    if (size == 0) {
      break;
    }
    vector<int> v(size);
    for (auto&& vv : v) {
      cin >> vv;
    }
    sort(v.begin(), v.end());
    cout << accumulate(v.begin() + 1, v.end() - 1, 0) / (v.size() - 2) << endl;
  }
  return 0;
}