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 <cstdio>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstdio>
#include <vector>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

main(){
    int n;

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

        vector <int> vec;
        for(int i = 0 ; i < n ; i++){
            int q;
            cin >> q;

            vec.push_back(q);
        }

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

        int sum = 0;

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

        cout << sum/(n-2) << endl;
    }
    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=0;
	if(A[j]>Max) Max=A[j];
    }
  for (int k=0; k<N; ++k){
    Min=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;
 }
}

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

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	int n;
	while(cin >> n && n)
	{
		vector<int> v(n);
		rep(i,n) cin >> v[i];

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

		int sum = 0;
		REP(i,1,v.size()-1) {
			sum += v[i];
		}

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

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){

  int n;

  int tensu[200];

  while(cin>>n,n){
	//cout << n << endl;//
	int max = 0;
	int min = 1000;
	int sum=0;
	REP(i,n){
	  cin >> tensu[n];
	  sum+=tensu[n];
	  if(max<tensu[n])
		max=tensu[n];
	  if(min>tensu[n])
		min=tensu[n];
	}

	//cout<<min<<endl<<max<<endl<<sum<<endl;//

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

  }

}

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

int main(void){
	int n,m,max,min,answer;
	while(1){
		cin >> n;
		max = 0;
		min = INT_MAX;
		answer = 0;
		if (!n) break;
		for (int i=0;i< n;i++){
			cin >> m;
			if (m > max) max = m;
			else if (m < min) min = m;
			answer += m;

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

	}

	return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<algorithm> 
#include<functional> 
#include<cassert>
#include<numeric> // std::accumulate(vec.begin(),vec.end(),0) sum of element
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<map>
#include<set>


using namespace std;


typedef long long ll;
typedef std::pair<int, int> P;
typedef vector<int> vi;


#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(c) c.begin(),c.end()
#define show(x) cout << #x << " = " << x << endl

#define fi first
#define se second
#define pb push_back



#define DEBUG


// void print_vector(const std::vector<int> &t);
// void unique_vector(std:: vector<int> &t);

template <class X>
void print_vector(const std::vector<X> &t);
template <class X>
void unique_vector(std:: vector<X> &t);


int n, m;

int main(){

  int n;
  vi ans;
  while(true){
    cin >> n;
    if(n == 0) break;
    vi sc(n);
    for(auto &i : sc) cin >> i;
    sort(sc.begin(), sc.end());
    sc.erase(sc.begin());
    sc.erase(sc.end()-1);
    int t = accumulate(sc.begin(), sc.end(), 0) / (n-2);
    ans.pb(t);
  }
  for(auto &i : ans) cout << i << endl;
}

template <class X>
void unique_vector(std::vector<X> &t)
{
  std::sort(t.begin(), t.end());
  t.erase( std::unique(t.begin(), t.end()), t.end() );
}

template <class X>
void print_vector(const std::vector<X> &t){
  for(auto itr=t.begin(); itr != t.end(); itr++){
    std::cout << *itr;
    if(itr != t.end()-1) std::cout << ' ';
  }
  std::cout << std::endl;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n1;
	cin >> n1;
	if (n1 > 0){
		int a[100000] = { 0 };
		for (int i = 0; i < n1; i++){
			cin >> a[i];
		}
		sort(a, a + n1);
		a[0] = { 0 };
		a[n1 - 1] = { 0 };
		for (int i2 = 1; i2 < n1; i2++){
			a[0] += a[i2];
		}
		cout << a[0] / (n1 - 2) << endl;

		return n1;
	}
		return 0;
}

C++: #include<algorithm>
#include<iostream>
#define rep(i,a) for(int i=0;i<(a);++i)

int n;

int main()
{
	while( std::cin >> n )
	{
		int ma = 0, mi = 1001, S = 0;
	
		rep( i, n )
		{
			int a;
			std::cin >> a;
			ma = std::max( ma, a );
			mi = std::min( mi, a );
			S += a;		
		}
		
		std::cout << (S-ma-mi)/n << std::endl;
	}

	return 0;
}

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

int main(){
  int n,score[100],i,sum,k=1;
  int max,min;

  while(k<=20){
    sum=0;
    max=0;
    min=1000;
    
    cin >> n;
    if(n==0)break;
    for(i=0;i<n;i++){
      cin >> score[i];
      if(max<score[i])max=score[i];
      if(score[i]<min)min=score[i];
      sum+=score[i];
    }
    sum-=(max+min);
    n-=2;
    cout<<(sum/n)<<endl;
    k++;
  }
  return 0;
}

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

int main()
{
  int n;
  while(cin >> n && n > 0)
    {
      int s[100];
      int max=-1, min=1001;
      int sum=0, ave=0;
      for(int i=0;i<n;i++)
	{
	  cin >> s[i];
	  sum += s[i];
	  if(s[i] > max)
	    max = s[i];
	  if(s[i] < min)
	    min = s[i];
	}
      sum -= (max + min);
      ave = sum/(n-2);
      cout << ave << endl;
    }
}

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

using namespace std;

int main() {
    int n, s;
    vector<int> v;

    while (true) {
        cin >> n;

        if (!n) { break; }

        // 全要素を削除
        v.clear();

        for (int i = 0; i < n; i++) {
            cin >> s;
            v.push_back(s);
        }

        int max_v = *max_element(v.begin(), v.end());
        int min_v = *min_element(v.begin(), v.end());
        int sum_v = accumulate(v.begin(), v.end(), 0);

        cout << (sum_v - max_v - min_v) / (n-2) << endl;
    }

    return 0;
}

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

int main()
{
	int n;
	int ary[100];
	while (cin >> n, n)
	{
		for (int i = 0; i < n; i++) cin >> ary[i];
		int Max = *max_element(ary, ary + n);
		int Min = *min_element(ary, ary + n);
		int Sum = accumulate(ary, ary + n, 0);
		cout << (Sum - Max - Min) / (n - 2) << endl;
	}

	return 0;
}