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

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for	{
		n := nextInt(sc)
		if n == 0 { break }

		score_list := []int{}
		for i := 0; i < n; i++ {
			score_list = append(score_list, nextInt(sc))
		}

		// 最低点と最高点を取り除く (3 ≤ n ≤ 100)
		sort.Sort(sort.IntSlice(score_list))
		score_list = score_list[1:len(score_list)-1]

		// 平均点を求める
		sum := 0
		for _, score := range score_list {
			sum += score
		}
		fmt.Println(sum / len(score_list))
	}
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

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

using namespace std;

int main()
{
	for (int i = 4; i > 1; i++) {
		int n;
		cin >> n;
		if (n == 0) break;
		vector<int> s(n);
		for (int b = 0; b < n; b++) {
			cin >> s[b];

		}
		
		int sum = 0;      // ????¨?????±????????????°
		for (int t = 0; t < n; t++) {
			// ??¨??¨???????´?????????????
			sum += s[t];    // ????¨??????????
		}
		
		int ma;
		int mi;
		ma = *max_element(s.begin(), s.end());
		mi = *min_element(s.begin(), s.end());
		
		double score;
		score = (sum - ma - mi) / (n - 2);
		cout << score << endl;
		

	}
}

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

int main() {
int n;
while(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; i++) {
if(i!=0 && i!=n-1) sum += a[i];
}

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

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

int main() {
  int n;
  while (1) {
    scanf("%d", &n);
    if (n == 0) break;
    int k;
    int maxn = -1;
    int minn = 1000000;
    int sum = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", &k);
      maxn = max(maxn, k);
      minn = min(minn, k);
      sum += k;
    }
    printf("%d\n", (sum - maxn - minn) / (n - 2));
  }
}

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

using namespace std;

int main()
{
    int n;
    vector<int> vi;
    while (cin >> n, n) {
        vi.clear();
        for (int i = 0; i < n; i++) {
            int s;
            cin >> s;
            vi.push_back(s);
        }
        sort(vi.begin(), vi.end());
        cout << accumulate(vi.begin()+1, vi.end()-1, 0) / (n-2) << endl;
    }
    return 0;
}

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

int main(){
    int a,n;
    for(;;){
        vector<int> num;
        cin>>n;
        if(n==0) break;
        for(int i = 0; i < n; i++){
            cin>>a;
            num.push_back(a);
        }
        sort(num.begin(), num.end());
        num.erase(num.begin());
         num.pop_back();
        int sum=0;
        for(int x : num){
            sum+=x;
        }
        sum/=num.size();
        cout<<sum<<endl;
    }
    return 0;
}

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

int main() {
  int n, s;
  int v[110];

  while (cin >> n && n > 0) {
    int sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> s;
      sum += s;
      v[i] = s;
    }
    sort(v, v + n);
    sum -= v[0];
    sum -= v[n-1];
    cout << sum/(n-2) << endl;
  }

  return 0;
}

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

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

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

int main() {
	int n, i, p[100], t = 0;
	int max = 0, min = 1000, maxi, mini;
	cin >> n;
	
	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;
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
 
int main() {
    int n, data;
    while(1) {
        scanf("%d", &n);
        if (n == 0) break;
        int sum=0, max=0, min=1001;
        for (int i=0; i<n; i++) {
            scanf("%d", &data);
            sum+=data;
            if (max < data) max=data;
            if (data < min) min=data;
        }
        printf("%d\n", (sum-max-min)/(n-2));
    }
}

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

using namespace std;

int main()
{

  while(1)
  {
	 int n;

	 cin >> n;
 
	 if(n == 0)break;

	 int Max = 0; 
	 int Min = 1001;
	 int Sum = 0;

	 for(int i = 0;i < n;i++)
	 {
	   int tmp;
	   cin >> tmp;
	   Sum += tmp;
	   Max = max(tmp,Max);
	   Min = min(tmp,Min);
	 }

	 Sum = Sum - Max - Min; 

	 cout << Sum/(n-2) << endl;
  }

  return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
 
using namespace std;
 
int main()
{
    int n;
    while(1){
        cin >> n;
        if(n == 0) break;
        int max = 0, min = 1000, sum = 0, score, ans;
        for(int i = 0; i < n; i++){
            cin >> score;
            sum += score;
            if(score > max) max = score;
            else if(score < min) min = score;
        }
        sum -= max + min;
        ans = sum / (n - 2);
        cout << ans << endl;
    }
    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

int input_count_trial() {
    int count;
    std::cin>>count;
    return count;
}

void display(int count_trial) {
    std::vector<int> scores;
    int score;
    for(int i=0; i<count_trial; i++) {
        std::cin>>score;
        scores.push_back(score);
    }
    std::sort(scores.begin(), scores.end());
    scores.erase(scores.begin());
    scores.erase(scores.end()-1);
    int sum = std::accumulate(scores.begin(), scores.end(), 0);
    int avarage = sum/(scores.size());
    std::cout << avarage << std::endl;
    return;
}

int main() {
    int count_trial = input_count_trial();
    do {
        display(count_trial);
        count_trial = input_count_trial();
    }while(count_trial!=0);
    return 0;
}

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

int main(){


  int n;

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

    //テ・ツ?・テ・ツ環?
    int point[200];
    for(int i = 0; i < n ; i++){
      cin >> point[i];
      //      cout << point[i] << " ";
    } 

    //max
    int max = -1;
    for(int i = 0 ; i < n ; i++){
      if(point[i] > max)
	max = point[i];
    }
    for(int i = 0 ; i < n ; i++){
      if(point[i] == max){
	point[i] = -1;
	break;
      }
    }

    //min
    int min = 10000;
    for(int i = 0 ; i < n ; i++){
      if(point[i] < min && point[i] != -1 )
	min = point[i];
    }
    for(int i = 0 ; i < n ; i++){
      if(point[i] == min){
	point[i] = -1; 
	break;     
      }
    }

    int ans = 0;
    for(int i = 0; i < n ; i++){
      if(point[i] > -1)
	ans += point[i];
      //  cout << point[i] << " ";
    }
    ans = ans / (n-2);
    cout << ans << endl;

  }

  return 0;
}