Go: /*
	Problem A: ICPC 得点集計ソフトウェア
	http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// 標準入力を取得するScannerのインスタンスを作成
var sc = bufio.NewScanner(os.Stdin)

// 標準入力で各行を読み込み文字列として返す
func readLine() string {
	if sc.Scan() {
		return sc.Text()
	}
	return ""
}

func average() (avg int) {
	// 審判の人数を取得する
	n, _ := strconv.Atoi(readLine())

	// 得点
	score := make([]int, 0, n)

	// 得点を読み込む
	for n > 0 {
		line, _ := strconv.Atoi(readLine())
		score = append(score, line)
		n--
	}

	if len(score) == 0 {
		return 0
	}

	// ソート
	sort.Ints(score)
	// 先頭を削除
	score = append(score[:0], score[1:]...)
	// 末尾を削除
	score = score[:len(score)-1]

	// 合計
	for i := 0; i < len(score); i++ {
		avg += score[i]
	}

	// 平均
	avg = avg / len(score)
	return avg
}

func main() {
	// 改行区切りから単語(スペース)区切りで読み込むように変更する
	sc.Split(bufio.ScanWords)
	for {
		avg := average()
		if avg != 0 {
			fmt.Println(avg)
		} else {
			break
		}
	}
}

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>
using namespace std;

int main() {
	int n, i, p[100], t;
	int max, min, maxi, mini;
	cin >> n;
	
	while (n != 0){
		max = 0; min = 1000; t = 0;

		for (i = 0; i < n; i++) {
			cin >> p[i];
		}

		for (i = 0; i < n; i++) {
			t += p[i];

			if (p[i] > max) {
				maxi = i;
				max = p[i];
			}

			if (p[i] < min) {
				mini = i;
				min = p[i];
			}
		}

		cout << (t - p[maxi] - p[mini]) / (n - 2) << endl;

		cin >> n;
	}
}

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

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

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

int main(){

  int n, s,  min, max;
  int total;
  while(cin >> n){
    total = 0;

   if(n == 0) break;

    for(int i=0; i<n; i++){
      cin >> s;
      if(i == 0){
	min = s;
	max = s;
      }
      if(s < min) min = s;
      if(s > max) max = s;
      total += s;
    }
    cout << (total-min-max)/(n-2) << endl; 
  }
  return 0;
}

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

C++: #include<stdio.h>
#include<math.h>

int main(void){
	
	int n,i,flag;
	int max,min;
	int readed,ans;
	double avg;
	
	while(1){
		
		flag = 0;
		
		scanf(" %d",&n);
		
		if(n==0){
			break;
		}
		
		for(i = 0;i < n;i++){
			
			scanf(" %d",&readed);
			
			if(flag == 0){
				max = readed;
				min = readed;
				flag = 1;
			}
			
			if(max < readed){
				max = readed;
			}
			
			if(min > readed){
				min = readed;
			}
			
			avg += readed;
		}
		
		avg -= max + min;
		
		avg /= n - 2;
		
		ans = (int)floor(avg);
		
		printf("%d\n",ans);
		
	}
	
	return(0);
	
}

C++: #include <iostream>

using namespace std;

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

C++: #include <iostream>

int main()
{
    int n, s = 0;
    std::cin >> n;

    int max, min, sum = 0;
    std::cin >> s;
    max = s;
    min = s;
    sum += s;

    for (int i = 0; i < n - 1; i++) {
        std::cin >> s;
        if (s > max)
            max = s;
        if (s < min)
            min = s;
        sum += s;
    }
    std::cout << (sum - max - min) / (n - 2) << '\n';

    return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
  while (true) {
    int n;
    cin >> n;
    if (n == 0)
      break;

    int score[100];
    for (int i = 0; i < n; i++)
      cin >> score[i];

    sort(score + 0, score + n);
    int sum = accumulate(score + 1, score + n - 1, 0);

    cout << sum / (n - 2) << endl;
    memset(score, 0, n);
  }
  return 0;
}

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


main(){
	int i,n,sum,mmin,mmax,t;
	while(cin>>n,n){
		sum=0;mmin=1000;mmax=0;
		for(i=0;i<n;i++){
			cin >> t;
			sum+=t;
			mmin = min(mmin,t);
			mmax = max(mmax,t);
		}
		cout << (sum-mmin-mmax)/(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;
}

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

int main(){
	int n;
	while(scanf("%d",&n),n){
		vector < int > vi;
		for(int i = 0; i < n; i++){
			int tmp;
			scanf("%d",&tmp);
			vi.push_back(tmp);
		}
		sort(vi.begin(),vi.end());
		double ave = 0.0;
		for(int i = 1; i < n-1 ;i++){
			ave += vi[i];
		}
		printf("%.0lf\n",ave/(n-2));
	}
	return 0;
}

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


int main(){
  while(true){
    int n;
    cin>>n;
    if(n==0){
      break;
    }
    int avn=n-2,s[n],total=0;
    for(int k=0;k<n;k++){
      cin>>s[k];
      total=total+s[k];
    }
    int max=0,min=1000;
    for(int i=0;i<n;i++){
      if(s[i]>max){
	max=s[i];
      }
      if(s[i]<min){
	min=s[i];
      }
    }
    total=total-max-min;
    total=total/avn;
    cout<<total<<endl;
  }

  return 0;
}

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

using namespace std;
int main(){
    int n=1;
    while (true){
        cin >> n;
        if(n==0) break;
        vector<int> a(n);
        for (int i = 0 ;i<n;i++){
            cin >> a[i];
         }
        sort(a.begin(),a.end());
        int sum=0;
        for (int i=0;i<n-1;i++){
            sum+=a[i];
        }
        cout << (float) sum /(float) (n-2)<<endl;
    }
}

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

int n,s[100];
int temp,ave,sum;

void sort(void){
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      if(s[i]>s[j]){
	temp=s[i];
	s[i]=s[j];
	s[j]=temp;
      }
    }
  }
}

int main(){
  while(cin >> n,n){
    for(int i=0;i<n;i++)
      cin >> s[i];  
    
    sort();
    
    sum=0;

    for(int i=0;i<n-2;i++)
      sum+=s[i+1];

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

C++: #include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e18;
const int inf=2e9;
const ll MOD=1000000007;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};

int main(){
    while(true){
        int N;cin>>N;
        if(N==0)break;
        int info[N];
        rep(i,N)cin>>info[i];
        sort(info,info+N);
        int sum=0;
        rep(i,N-2)sum+=info[i+1];
        int ans=sum/(N-2);
        cout<<ans<<endl;
    }
    return 0;
}