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

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