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>
typedef long long ll;
using namespace std;
int main(){
  ll N;
  ll s[1100];
  ll sum=0;
  ll t=1;
  while(N){
  cin >>N;
  for(ll i = 0; i < N; ++i){
      cin >> s[i];
  }
  sort(s,s+N);
  for(ll i = 1; i < N-1; ++i){
    sum+=s[i];
  }
  cout<<sum/(N-2)<<endl;
  cin>>N;
}
}

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

int main(){
	int n, s, sum, max, min, i;
	while((cin >> n), n){
		sum = max = 0;
		min = 1000;
		for(i = 0; i < n; i++){
			cin >> s;
			sum += s;
			max = max(max, s);
			min = min(min, s);
		}
		cout << (int)(sum / n) << endl;
	}
}

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

int n, sum, l, s;

int main() {
  
  int a;
  while(cin>>n,n) {
    cin>>a;
    sum = a;
    l = a;
    s = a;
    for(int i=1;i<n;i++) {
      cin>>a;
      if(a>l)l=a;
      else if(a<s)s=a;
      sum+=a;
    }
    sum -= l+s;
    sum = sum/(n-2);
    cout<<sum<<endl;
  }
  
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
int n;
while(cin >> n, n){
vector<int> v(n);
for(int i = 0; i < n; i++){
cin >> v[i];
}
sort(v.begin(), v.end());
int sum = 0;
for(int i = 1; i < n-1; i++){
sum+=v[i];
}
cout << sum / (n-2) <<endl;
}


}

C++: #include <stdio.h>
 
int main() {
 
  int n,a[100] = {0};
  int i,j,k,l;
  int sum;
  int suma[30];
  j = 0;
  while(1) {
 int max = -1;
  int min = 10001;
   sum = 0;
 
  scanf("%d",&n);
  if(n == 0){
    break ;}
 
  for(i=0;i<n;i++) {
 
    scanf("%d",&a[i]);
    sum = sum + a[i];
    if(min > a[i] ) {
      min = a[i];
    } if( max < a[i]) {
      max  = a[i];
    }
  } 
 sum = (sum-max-min) / (n-2);
 suma[j] = sum;
 j++;
 
  }
 
  //  printf("sum = %d\n",sum);
  // printf("max = %d min = %d",max,min);
 
  for(i = 0; i < j; i++) {
 
  printf("%d\n",suma[i]);
   
  }
 
  return 0;
 
}

C++: #include<iostream>
using namespace std;
int main(){
    int n,i;
    while(cin >> n,n){
		int p;
        int min = 1000;
        int max = 0;
		int total = 0;
		for(int i=0;i<n;i++){
			cin >> p;
			if(p > max) max = p;
			if(p < min) min = p;
			total += p;
        }
        cout << (total-max-min)/(n-2) << "\n";
    }
}

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

int a[10];
int n;
int s[100];
int s_max, s_min;
int sum = 0;
int ave = 0;

int main() {
  while(cin >> n, n)
  {
  for(int i =0; i < n; i++){
    cin >> s[i];
  }
  
  s_max = *max_element(s, s + n);
  s_min = *min_element(s, s + n);

  sum = accumulate(s, s + n, 0);

  sum = sum - s_max - s_min;

  ave = sum/(n-2);
  cout << ave << endl;
  }
  return 0;
}

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

int main() {
	int n;
	while(cin >> n, n != 0) {
		vector<int> v(n);
		for(int i = 0; i < n; ++i) {
			cin >> v[i];
		}
		
		sort(v.begin(), v.end());
		
		int ans = 0;
		
		for(int i = 1; i < n - 1; ++i) {
			ans += v[i];
		}
		
		cout << ans / (n - 2) << endl;
	}
	return 0;
}

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

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

int n,s;

int main(){
    while(cin>>n&&n){
	int sum=0,M=0,m=1000;
	rep(i,n){cin>>s;sum+=s;if(s>M)M=s;if(s<m)m=s;}
	cout<<(sum-M-m)/(n-2)<<endl;
    }
}

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

int main(){
	int n;
	while(cin >>n){
		if(n == 0) break;
		vector<int> vec;
		int tmp, max, min;
		cin >>tmp;
		vec.push_back(tmp);
		max = tmp;
		min = tmp;
		bool maxb = true, minb = true;
		for(int i = 1; i < n; i++){
			cin >>tmp;
			vec.push_back(tmp);
			if(tmp < max) max = tmp;
			if(tmp > min) min = tmp;
		}
		int sum = 0;
		for(int i = 0; i < vec.size(); i++){
			if(vec[i] == max && maxb){
				maxb = false;
			} else if(vec[i] == min && minb){
				minb =false;
			} else{
				vec[i] += sum;
			}
		}
		cout <<(sum / (n - 2)) <<endl;
		return 0;
	}
}

C++: #include <iostream>
#include <queue>

using namespace std;

int main() {

	int N, shortest, largest, sum, tmp;

	while (true) {
		cin >> N;
		if (N == 0)
			break;

		sum = 0;
		shortest = 10000;
		largest = -1000;

		for (int i = 0; i < N; i++) {
			cin >> tmp;
			sum += tmp;
			shortest = min(shortest, tmp);
			largest = max(largest, tmp);
		}

		sum -= shortest;
		sum -= largest;

		cout << sum / (N - 2) << endl;

	}

	return 0;
}

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

int n, sum, l, s;

int main() {
  
  int a;
  while(cin>>n,n) {
    cin>>a;
    sum = a;
    l = a;
    s = a;
    for(int i=1;i<n;i++) {
      cin>>a;
      if(a>l)l=a;
      else if(a<s)s=a;
      sum+=a;
    }
    sum = sum/(n-2);
    cout<<sum<<endl;
  }
  
  return 0;
}

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

int main(){
  int n, s, sum, max, min;
  while(1){
    cin >> n;
    if(n == 0) break;
    sum = 0;
    cin >> s;
    sum += s;
    max = s;
    cin >> s;
    sum += s;
    if(max < s){
      max = s;
    }else{
      min = s;
    }
    for(int i = 2; i < n; i++){
      cin >> s;
      sum += s;
      if(max < s) max = s;
      if(min > s) min = s;
    }
    sum -= max;
    sum -= min;
    int ave = sum / (n-2);

    cout << ave << endl;
  }

  return 0;
}

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

int main(){
	int n;
	while(std::cin >> n, n){
		std::vector<int> v;
		for(int i=0;i<n;i++){
			int j;
			std::cin >> j;
			v.push_back(j);
		}
		std::sort(v.begin(), v.end());
		int ave = 0;
		for(int i=1;i<v.size()-1;i++){
			ave += v[i];
		}
		ave /= n-2;
		std::cout << ave << std::endl;
	}
}

C++: //05
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    double h=-1,l=1<<30,sum=0;
    for(int i=0;i<n;i++){
      double s;
      cin>>s;
      sum+=s;
      h=max(s,h);
      l=min(s,l);
    }
    cout<<int((sum-h-l)/(n-2))<<endl;
  }
  return 0;
}

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

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

int main(){
        int n;
        while(cin>>n&&n){
                ll ans=0;
                vector<int>s(n);
                for(int i=0;i<n;i++){
                        cin>>s[i];
                        ans+=s[i];
                }
                sort(s.begin(),s.end());
                ans=ans-s[0]-s[n-1];
                cout<<ans/(n-2)<<endl;
        }
        return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

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

int main(void){
  int n;
  while(cin>>n){
    if(n==0) break;
    vector<int> a(n);
    REP(i,n)cin>>a[i];
    int s = accumulate(a.begin(),a.end(),0)- *min_element(a.begin(),a.end())
      - *max_element(a.begin(),a.end());
    cout<<s/(n-2)<<endl;
  }
  return 0;
}

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

using namespace std;

int main() {
	int a[20];
	int b,sum=0,point;
	while(1){
		cin >> b;
		if(b==0) break;
		for(int i=0;i<b;i++){
			cin >> a[i];
			
		}
		sort(a,a+b);
		for(int j=1;j<b-1;j++){
			sum+=a[j];
		}
		point=sum/(b-2);
		cout << point << endl;
		sum=0;
		
	}
	return 0;
}