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())
		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 < n-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

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

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

int main() {

  while( true ) {
    long long int n, input;
    cin >> n;

    if ( n == 0 ) break;

    vector< long long int > s;

    for ( long long int i = 0; i < n; i++ ) {

      cin >> input;
      s.push_back( input );

    }

    sort( s.begin(), s.end() );

    long long int ans = 0;

    for ( long long int i = 1; i < n - 1; i++ ) {

      ans += s[i];

    }

    cout << ans / ( n - 2 ) << endl;

  }

  return 0;

}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
using namespace std;

typedef vector<int> Ivec;
int main() {
	int n;
	
	while (scanf("%d", &n) != EOF) {
		if (n == 0)
			return 0;
		int Sum = 0, Max = -1, Min = 1001, num[2];
		for (int i = 0; n > i; i++) {
			int buf;
			scanf("%d", &buf);
			if (buf > Max) {
				Max = buf;
				num[0] = i;
			}
			if (buf < Min) {
				Min = buf;
				num[1] = i;
			}
			Sum += buf;
		}
		printf("%d\n", (int)((Sum - (num[0] == num[1] ? Max : Max+Min))/(n- (num[0] != num[1]) - 1)));
	}
	return 0;
}

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

int main()
{
	int N, n, sum, largest, smallest;
	
	while(cin >> N && N>0){
		sum  = 0; largest = 0; smallest = 1000;
		for(int i = 0; i<N; i++)
		{
			cin >> n;
			sum += n;
			
			if(smallest > n){ smallest = n;}
			if(largest < n){ largest = n;}
		}
	
		cout << (sum-smallest-largest)/(N-2) << endl;
	}
}

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

int main(){
    int n;
    while(cin >> n){
        vector<int> judges;
        for(int i=0; i<n; i++){
            int score;
            cin >> score;
            judges.push_back(score);
        }
        sort(judges.begin(), judges.end());
        judges.erase(judges.begin());
        judges.pop_back();

        int sum = accumulate(judges.begin(), judges.end(), 0);
        int score = sum / judges.size();
        cout << score << endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n,n!=0){
    vector<int> point(n);
    for(int i=0;i<n;i++)
      cin>>point[i];
    sort(point.begin(),point.end());
    int ave=0;    
    for(int i=1;i<n-1;i++)
      ave+=point[i];
    ave/=(n-2);
    cout<<ave<<endl;
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int larger(int x,int y) {
	int z = 0;
	if (x > y)z = x;
	else z = y;
	return z;
}
int smaller(int x, int y) {
	int z = 0;
	if (x < y)z = x;
	else z = y;
	return z;
}
int main(void) {
	int s = 1;
	while (s == 1) {
		int sinsa, a[100], sum = 0, ave;
		cin >> sinsa;
		if (sinsa == 0)s = 2;
		for (int i = 0; i < sinsa; i++) {
			cin >> a[i];
		}
		int n = a[0];
		for (int i = 0; i < sinsa; i++) {
			n = larger(n, a[i]);
		}
		int m = a[0];
		for (int i = 0; i < sinsa; i++) {
			m = smaller(m, a[i]);
		}
		for (int i = 0; i < sinsa; i++) {
			sum += a[i];
		}
		sum = sum - n - m;
		ave = sum / (sinsa - 2);
		cout << ave<<endl;
	}

	return 0;

}

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

using namespace std;

int main(){
	int n;
	while(cin >> n,n){
		int a[100];
		for (int i = 0; i < n; ++i) cin >> a[i];
		sort(a,a+n);
		int sum = 0;
		for (int k = 1; k < n-1; ++k){
			// cout << a[k] << " ";
			sum += a[k];
		}
		// cout << n << endl;
		cout << sum/(n-2) << endl;	
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(void)
{

	int num;
	int ave;
	
	while (cin >> num && num != 0 )
	{
		int a[num];
		int sum = 0, max = 0, min = 1000;
		for(int i = 0;i < num; i++)
		{
			cin >> a[i];
			sum += a[i];
			if(a[i] <= min)
				min = a[i];
			if(a[i] >= max)
				max = a[i];
		}
		ave = (sum - max - min) / (num - 2);
		cout << ave << endl;
	}

	return 0;
}

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 <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <complex>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000009LL
 
LL k[100][10000];

int main(){
    while(1){
        int n;
        cin >> n;
        if(n==0)return 0;
        VI v;
        int s=0;
        REP(i,n){
            int tmp;
            cin >> tmp;
            v.PB(tmp);
        }
        SORT(v);
        FOR(i, 1, n-1)s+=v[i];
        cout << s/(n-2) << endl;
    }
}

C++: #include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(!n){
			break;
		}
		vector<int> score;
		int in;
		for(int i=0;i<n;i++){
			cin>>in;
			score.push_back(in);
		}
		sort(score.begin(),score.end());
		int sum=0;
		for(int i=1;i<score.size()-1;i++){
			sum+=score[i];
		}
		int avr=sum/(n-2);
		cout<<avr<<endl;
	}
	return 0;
}