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

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

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

using namespace std;

int main() {
    int n;

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

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

        sort(s.begin(), s.end());
        int sum = 0;
        for (int i = 1; i < n - 1; i++) {
            sum += s[i];
        }

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

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

using namespace std;

int main() {
	int n,sum=0;
	vector<int> v;
	for (;;) {
		cin >> n;
		if (n == 0)break;
		v.resize(n);
		for (int i = 0; i < n; i++) {
			cin >> v[i];
		}
		sort(v.begin(), v.end());
		for (int i = 1; i < n - 1; i++) {
			sum += v[i];
		}

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

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



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll n;
    while(cin>>n){
        if(n==0) break;
        ll ans = 0;
        ll a[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
            ans += a[i];
        }
        ans -= *max_element(a,a+n) + *min_element(a,a+n);
        ans /= (n-2);
        cout << ans << endl;
    }
}

C++: #include <iostream>
using namespace std;
int main()
{
  int n[20]={};
  int s[20][100]={};
  int answer[20]={};
  int MAX=-1,min=1001,jM=0,jm=0;
  int i=0,j=0;

  for(;;i++){
    cin >> n[i];//?????°??\???
    if(n[i]>=3&&n[i]<=100){
      for(MAX=-1,min=1001,j=0;j<n[i];j++){//?????°?¶??????????
	cin >> s[i][j];
	if(MAX<s[i][j]){//?????§????±???????
	  MAX=s[i][j];
	  jM=j;
	}
	if(min>s[i][j]){//????°??±???????
	  min=s[i][j];
	  jm=j;
	}
	answer[i]+=s[i][j];
      }
      
      answer[i]=(answer[i]-s[i][jM]-s[i][jm])/(n[i]-2);
    }else{
      break;
    }
  }
  for(i=0;n[i]>=3&&n[i]<=100;i++){//??????
    cout << answer[i] << endl;
  }
}

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

int main (){
	int n, i, max, min;
	int A[101];
	int sum;
	while (cin >> n && n > 0){
		sum = 0;
		for (i = 0; i < n; i++){
			cin >> A[i];
		}
		max = min = A[0];
		for (i = 0; i < n; i++){
			if (max < A[i]){
				max = A[i];
			}
			if (min > A[i]){
				min = A[i];
			}
			sum += A[i];
		}
		sum -= max;
		sum -= min;
		cout << sum / (n - 2) << endl;
	}

	return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int MOD=1000000007;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;


int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		int ans=0,s[110];
		rep(i,0,n)cin>>s[i];
		sort(s,s+n);
		rep(i,1,n-1)ans+=s[i];
		print(ans/(n-2));
	}
	return 0;
}

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

class foo{
public:
  int icpc(int n){
    int ma=0, mi=1000, sum=0,s;
		for(int i=0;i<n;i++){
			cin >> s;
			ma=max(ma, s);
			mi=min(mi, s);
			sum+=s;
		}
		return (sum-ma-mi)/(n-2);
  }
  
  int main(){
    int n;
	  while(true){
  		cin >> n;
		  if(!n)return 0;
		  cout << icpc(n) << endl;
	  }
    return 0;
  }
};

int main(){return (new foo)->main();}

C++: #include <iostream>

int main() {
    using namespace std;

    int c;
    int num;
    int max ;
    int min;
    int sum;
    int ans;
    while(true){
        max = 0;
        min = 1001;
        sum = 0;
        cin >> c;
        if(c == 0){
            break;
        }
        for(int i = 0; i < c; i++){
            cin >> num;
            if(num > max){
                max = num;
            }
            if(num < min){
                min = num;
            }
            sum += num;
        }
        ans = (sum - max - min)/(c-2);
        cout << ans << "\n";
    }
    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;
    max = s;
    cin >> s;
    if(max < s){
      max = s;
    }else{
      min = s;
    }
    for(int i = 0; i < n -2; 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<cmath>
#include<iomanip>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<string>
#include<stdlib.h>

using namespace std;
#define rep(i,n) for(auto i=(n)*0;i<n;i++)
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	cout << fixed << setprecision(30);
	int n;
	while (cin >> n, n){
		int top = 0, bottom = 1000,sum=0;
		rep(i, n){
			int s;
			cin >> s;
			sum += s;
			top = max(top, s);
			bottom = min(bottom, s);
		}
		cout << sum - top - bottom << endl;
	}
	return 0;
}

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

int main()
{
  int ave[20];
  int jsup=0;
  for(int j=0;j<20;j++)
    {
      int n;
      cin >> n;
      if(n==0)
	{
	jsup = j;
	break;
	}
      int s[100];
      int max=-1, min=1001;
      int max_i = -1, min_i=-1;
      for(int i=0;i<n;i++)
	{
	  cin >> s[i];
	  if(s[i] > max)
	    {
	      max = s[i];
	      max_i = i;
	    }
	  if(s[i] < min)
	    {
	      min = s[i];
	      min_i = i;
	    }
	  if(i == n-1 && max == min)
	    min_i = max_i+1;
	}
      int sum=0;
      for(int i=0;i<n;i++)
	{
	  if(i==max_i || i==min_i)
	    continue;
	  else
	    sum += s[i];
	}
      ave[j] = sum/(n-2);
    }
  for(int j=0;j<jsup;j++)
    {
      cout << ave[j] << endl;
    }
}

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

int main(){
    int n;

    while(!cin.eof()){
        vector<int> point;
        int data;
        int ave=0;

        cin>>n;
        for(int i=0; i<n; i++){
            cin>>data;
            point.push_back(data);
        }
        sort(point.begin(), point.end());
        for(int i=1; i<point.size()-1; i++){
            ave+=point[i];
        }
        cout<<ave/(point.size()-2)<<endl;
    }

    return 0;
}

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

using namespace std;

int n, s;
int main(){
    while(cin >> n && n>0){
        int sum = 0, max=0, min=10000 , temp;
        for (int i = 0; i<n; i++){
            cin >> s;
            if (s > max){
                sum += max;
                max=s;
            }
            else{
                if (s < min){
                    if(min != 10000){
                        sum += min;
                        min=s;
                    }
                    else{
                        min=s;
                    }
                }
                else{
                    sum += s;
                }
            }
            if (max < min){
                max = temp;
                min = max;
                max = temp;
            }
        }
        cout << sum/(n-2) << endl;
    }
}