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>
int main()
{
    int n, s[20], i;
    int max, min, ava, sum;
    while (1)
    {
        max = 0;
        min = 1000;
        sum = 0;
        scanf("%d", &n);
        if (n == 0)
        {
            break;
        }
        for (i = 0; i < n; i++)
        {
            scanf("%d", &s[i]);
            if (max < s[i])
            {
                max = s[i];
            }
            if (min > s[i])
            {
                min = s[i];
            }
            sum += s[i];
        }
        sum -= max;
        sum -= min;
        ava = sum / (n - 2);
        printf("%d\n", ava);
    }
}

C++: #include <iostream>
#include <stdlib.h>
using namespace std;
int N, S;
int main()
{
  while (cin >> N && N > 0){
    if (N<3 || N>100)
      exit (1);
    int sum = 0;
    int largest = 0;
    int smallest =1000;
    for (int i=0; i<N; ++i){
      cin >> S;
      if (S<0 || S>1000)
        exit (2);
      sum += S;
      if (largest < S)
        largest=S;
      if (smallest > S)
      smallest=S;
    }
    int average = 0;
    average = (sum - largest - smallest) / (N - 2);
    cout << average << endl;
  }
}

C++: #include <stdio.h>
int max(int a,int b){
    if(a>b)return a;
    return b;
}
int min(int a,int b){
    if(a>b)return b;
    return a;
}
int main(){
    int n,top,bot,tot,temp;
    while(1){
        scanf("%d",&n);
        if(n==0)return 0;
        scanf("%d",&top);
        tot=bot=top;
        for(int i=1;i<n;i++){
            scanf("%d",&temp);
            tot+=temp;
            top=max(top,temp);
            bot=min(bot,temp);
        }
        printf("%d\n",(tot-top-bot)/(n-2));
    }
}

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

int main(){
  int n,a[21],b[21];
  while(1){
    
    cin>>n;
    if(n==0) break;
    for(int i=0;i<n;i++){
      cin>>a[i];
    }
    
    int max=0,min=10001;
    for(int i=0;i<n;i++){
      if(max<a[i]){
	max=a[i];
      }
      if(min>a[i]){
	min=a[i];
      }
    }
    
    int sum=0;
    for(int i=0;i<n;i++){
      sum+=a[i];
    }
    sum-=(max+min);
    
    cout<<sum/(n-2)<<endl;
  }
  return 0;
}

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

int main(void){
	int n;
	while(cin>>n,n){
	valarray<int> a(n);
		for(int i=0;i<n;i++)cin>>a[i];
		cout<<(a.sum()-a.max()-a.min())/(a.size()-2)<<endl;
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
 
  while( true ) {
    long long int n;
    long long int a = 0;
    long long int b = 0;
    int input[100];
    cin >> n;
 
    if ( n == 0 ) break;
  
    for ( long long int i = 0; i < n; i++ ) {
 
      cin >> input[i];

      if (input[i] < a)
        a = input[i]

      if (input[i] > b)
        b = input[i] 
    }
 
    long long int ans = 0;
 
    for ( long long int i = 0; i < n; i++ ) {
 
      ans += s[i];
 
    }
 
    cout << (ans - a - b) / ( n - 2 ) << endl;
 
  }
 
  return 0;
 
}

C++: #include <cstdio>
int main()
{
    int n, s[20], i;
    int max, min, ava, sum;
    while (1)
    {
        max = 0;
        min = 1000;
        sum = 0;
        scanf("%d", &n);
        if (n == 0)
        {
            break;
        }
        for (i = 0; i < n; i++)
        {
            scanf("%d", &s[i]);
            if (max < s[i])
            {
                max = s[i];
            }
            if (min > s[i])
            {
                min = s[i];
            }
            sum += s[i];
        }
        sum -= max;
        sum -= min;
        ava = sum / (n - 2);
        printf("%d\n", ava);
    }
    return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  while(cin >> n&&n){
    vary(ll,v,n,0);
    rep(i,n){
      cin >> v[i];
    }
    sort(all(v));
    v[0] = 0;
    v[v.size()-1] = 0;
    ll ans = 0;
    rep(i,n){
      ans += v[i];
    }
    cout << ans /(n-2) << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
const int INF = 1e9;
const int MODk = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    int n;
    while(cin >> n){
        if(n == 0){
            return 0;
        }
        vector<int> s;;
        for(int a = 0;a < n;a++){
            int b;cin >> b;
            s.push_back(b);
        }
        sort(s.begin(),s.end());
        cout<<(accumulate(s.begin(),s.end(),0LL)-*max_element(s.begin(),s.end())-*min_element(s.begin(),s.end()))/(max(n-2,0))<<endl;;
    }
}

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

using namespace std;

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






}

C++: #include <iostream>
using namespace std;
int N, S;

int main(){
  while( cin >> N && N > 0){ //N??????????????????????????????????????§while????????????
    int sum = 0; 
    int min = 1001; //min????°?????????¨?????????
    int max = -1;
    int average = -1;

    for (int i = 0; i < N; i++){
      cin >> S;
      sum += S;
      if( S > max ) max = S;
      if(S < min) min = S; 
    }

    average = (sum - min - max) / (N - 2); //???N-2?????§???????????¨?????¨??????????????????????????¨????????????????????????

    cout << average << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
using namespace std;

int main(){
	int N,S;
	while(cin>>N,N){
		int sum=0,min_=INT_MAX,max_=INT_MIN;
		for(int i=0;i<N;i++){
			cin>>S;
			min_ = min(min_,S);
			max_ = max(max_,S);
			sum += S;
		}
		printf("%d\n",(sum-min_-max_)/(N-2));
	}
	return 0;
}