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 <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <cctype>

#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <algorithm>


using namespace std;

#define Max INT_MAX
#define Inf (INT_MAX/2)
#define Min INT_MIN


#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i,l,n) for(int (i)=(int)(l);(i)<(int)(n);(i)++)
// s <= x < g ?
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
// 0 <= x < w && 0 <= y < h ?
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))

typedef pair<int, int> P;

int main()
{
    int n;
    while( cin >> n ){
        vector<int> vec;
        if( n == 0) {break;}
        rep(i,n){
            int tmp;
            cin >> tmp;
            vec.push_back(tmp);
        }
        sort(vec.begin(), vec.end());
        double sum = 0.0;
        for( int i = 1; i<vec.size() - 1; i++ ){
            cout << "add" << i << endl;
            sum += double(vec[i]);
        }
        cout << floor(sum/double(vec.size()-2) ) << endl;
    }
    return 0;
}

C++: /*
 * tokuten_syukei_software.cpp
 *
 *  Created on: 2017/02/02
 *      Author: Nishio
 */
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
using namespace std;

int main(){
	int N;
	while(cin>>N,N){
		int mx=0,mn=1000,sum=0;
		int s[N];
		for(int i=0;i<N;i++){
			cin>>s[i];
			sum+=s[i];
			mx=max(mx,s[i]);
			mn=min(mn,s[i]);
		}
		sum-=mx+mn;
		sum/=N-2;
		p(sum);
	}

	return 0;
}

C++: #include <cstdio>

using namespace std;

int main(){
  int min,max,sum,n,score;

  while(1){
    scanf("%d",&n);
    if(!n) break;

    max=0;min=10000;sum=0;

    for(int i=0;i<n;i++){
        scanf("%d",&score);
        if(max<score) max=score;
        if(min>score) min=score;
        sum+=score;
    }

    printf("%d\n",(sum-max-min)/(n-2));
  }
    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<random>
#include<string>
typedef long long ll;
using namespace std;
int main(){
  ll N;
  ll s[1100];
  ll sum=0;
  ll t=0;
  while(t<=20){
  s++;
  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;
}
}

C++: #include <iostream>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <bitset>
#include <tuple>

using namespace std;

int main(void)
{
  while (true) {

    int n;
    cin >> n;
    if (n == 0) break;
    int p[n];
    for (int i = 0; i < n; i++)
      cin >> p[i];
    int top,bottom,sum;
    top = -1;
    bottom = 1001;
    sum = 0;
    for (int i = 0; i < n; i++) {
      if (top < p[i])
	top = p[i];
      if (bottom > p[i])
	bottom = p[i];
    }
    //cout << top << "  " << bottom << endl;
    
    bool t, b;
    t = b = true;
    for (int i = 0; i < n; i++) {
      if (top == p[i] && t) {
	t = false;
      }
      else if (bottom == p[i] && b) {
	b = false;
      }
      else
	sum+=p[i];
    }
    cout << (int)(sum/(n-2)) << endl;
    
  }
  return 0;	
}

C++: #include<stdio.h>

void QSort(int x[ ], int left, int right);
void Swap(int x[ ], int i, int j);

void QSort(int x[ ], int left, int right)
{
    int i, j;
    int pivot;

    i = left;                   
    j = right;                  

    pivot = x[(left + right) / 2];
    while (1) {                   

        while (x[i] < pivot)      
            i++;                  

        while (pivot < x[j])      
            j--;                  
        if (i >= j)               
            break;                

        Swap(x, i, j);            
        i++;                      
        j--;
    }

    if (left < i - 1)              
        QSort(x, left, i - 1);     
    if (j + 1 <  right)            
				QSort(x, j + 1, right);    
		}

void Swap(int x[ ], int i, int j)
{
    int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}

int main(void)
{
	int i;
	int j;
	int k;
	int n;
	int d[20];
	int p[100];
	int sum;
	int ave;
	
	j=0;
	while(1){


		scanf("%d",&n);
		if(n==0) 
			break;
			
		for(i=0;i<n;i++){
		scanf("%d",&p[i]);
		}

		QSort(p,0,n-1);	
	
		sum = 0;
		for(i=1;i<n-1;i++){
			sum += p[i];
		}
			
			d[j] = sum / (n-2);
			j++;

	}
	
	for(k=0;k<j;k++)
		printf("%d\n",d[k]);

	return 0;
}

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

int main() {
  while(true){
    int a;
    cin >> a;

    if(a == 0){
      break;
    }

    vector<int> b(a);
    int max = -9999;
    int min = 99999;
    int maxi,mini;
    for(int i = 0; i < a; i++){
      cin >> b[i];
      if (max < b[i]) { max = b[i];maxi = i; }
      if (min > b[i]) { min = b[i];mini = i; }
    }
    b[mini] = 0;
    b[maxi] = 0;

    int sum = 0;
    for(int i = 0; i < a; i++){
      sum += b[i];
    }
    cout << sum / (a - 2) << endl;
  }
}

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

int main(void){
    while(true){
        int n, min=10000, max=-1, sum=0;
        cin >> n;
        if(n==0) break;
        for(int i=0;i<n;++i){
            int s;
            cin >> s;
            sum += s;
            max = (max > s)? max: s;
            min = (min < s)? min: s;
        }
        cout << (sum-max-min)/(n-2) << endl;
    }
}

C++: #include <bits/stdc++.h>

using namespace std;

typedef long long ll;

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

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

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

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <queue>

#pragma warning( disable: 4996 )

using namespace std;

typedef long long ll;

#define INF 100000000
#define EPS 1e-9

#define MAX_N 100

int n;
vector<int> ans_list;

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

		vector<int> score;

		for (int i = 0; i < n; i++){
			int s;
			cin >> s;
			score.push_back(s);
		}
	
		sort(score.begin(), score.end());

		int ans = 0;

		for (int i = 1; i < score.size() - 1; i++){
			ans += score[i];
		}

		ans_list.push_back(ans / (score.size() - 2));
	
	}

	for (int i = 0; i < ans_list.size(); i++){
		cout << ans_list[i] << endl;
	}

	return 0;

}