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 <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
int main()
{
	int n;
	while(1)
	{
		cin >> n;
		if(n==0)break;
		vector<int> vec(n);
		for(int i=0;i<n;i++)cin >> vec[i];
		sort(all(vec));
		cout << accumulate(vec.begin()+1,vec.end()-1,0)/(n-2) << endl;
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int main () {
  while (true){
    int n,i;
    int s = 0;
    int mi = 0;
    int ma = 0;
    cin >> n;

    if (n == 0)
      break;
??????
??????int point[n];

    for (i=0,i<n,i++){
      cin >> point[i];

      if (point[i] < mi)
        mi << point[i];

      if (point[i] > ma)
        ma << point[i];

      s += point[i];
    }

    cout << (s - mi - ma) / (n-2) << endl
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int N, S;
int main()
{
	/* code */
	while (cin >> N && N >0){
		int sum = 0;
		for(int i=0; i<N; i++){
			cin >> S;
			sum += S;
		}
		cout << sum << endl;
	}

}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <sstream>
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;

const int MAX_s = 1005;
int n, m, M, S, s;

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

        S = 0;
        m = MAX_s;
        M = 0;
        for(int i = 0; i < n; i++) {
            cin >> s;
            S += s;
            m = min(m, s);
            M = max(M, s);
        }

        cout << (int)((S - m - M) / (n - 2)) << endl;
    }

    return 0;
}

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

C++: #include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    
    /////////
    //write//
    /////////
    
    while (1){
        int n; cin >> n;
        if(n==0)break;
        int s[1000] = {0};
        for(int i=0; i<n; i++){
            cin >> s[i];
        }
        
        sort(s, s+n);
        
        int sum = 0;
        for(int i=1; i<n-1; i++){
            sum+=s[i];
        }
        sum/=(n-2);
        
        cout << sum << endl;
    }
    return 0;
}

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

int main(){
	int n;
	while (std::cin >> n && n){
		std::vector<int> score;
		for (int i = 0; i < n; ++i){
			int s;
			std::cin >> s;
			score.push_back(s);
		}
		std::sort(score.begin(), score.end());
		score.pop_back();
		score.erase(score.begin());
		int ans = 0;
		int cnt = 0;
		for (auto it = score.begin(); it != score.end(); ++it){
			ans += *it;
			cnt++;
		}
		std::cout << ans/cnt << std::endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    while(N){
        int sum = 0,a,maxi = INF,mini = 0;
        rep(i,0,N){
            cin >> a;
            sum += a;
            maxi = max(maxi, a);
            mini = min(mini, a);
        }
        sum -= (maxi + mini);
        cout << sum / N << endl;
        cin >> N;
    }
}

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

int main() {
    int n;
    while (cin >> n, n) {
        vector<int> s(n);
        for (auto &si: s) cin >> si;
        sort(s.begin(), s.end());
        int sum = accumulate(s.begin(), s.end(), 0) - s.front() - s.back();
        cout << sum / (n - 2) << endl;
    }
    return 0;
}

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

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

}

C++: #include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>

#define BIT(a) (1 << (a))

using namespace std;

long long MOD = 1000000007;


long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

vector<int> v[30];
int ans[30];
int main(void){
	int N;
	int cnt = 0;
	while (1){
		cin >> N;
		if (N == 0) break;
		for (int i = 0; i < N; i++){
			int x;
			cin >> x;
			v[cnt].push_back(x);
		}
		cnt++;
	}
	for (int i = 0; i < cnt; i++){
		sort(v[i].begin(), v[i].end());
		for (int j = 0; j < v[i].size(); j++){
			if (j == 0 || j == v[i].size()-1) continue;
			ans[i] += v[i][j];
		}
		ans[i] /= v[i].size() - 2;
	}

	for (int i = 0; i < cnt; i++){
		cout << ans[i] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
using llong = long long;

llong n;
llong sum;
llong m;

int main() {

    while (scanf("%lld", &n), n != 0) {
        llong minv = 1ll << 60ll;
        llong maxv = -1;
        sum = 0;
        
        for (int i = 0; i < n; i++) {
            cin >> m;

            sum += m;

            minv = min(minv, m);
            maxv = max(maxv, m);
        }

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

    return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int n,s[120],count;;
	while(true){
		cin>>n;
		if(n==0)
			break;
		count=0;
		for(int i=0;i<n;i++){
			cin>>s[i];
			count+=s[i];
		}
		for(int i=0;i<n-1;i++){
			for(int j=n-1;j>i;j--){
				if(s[j]<s[j-1]){
					int tmp=s[j];
					s[j]=s[j-1];
					s[j-1]=tmp;
				}
			}
		}
		count-=s[0];
		count-=s[n-1];
		cout<<count/(n-2)<<endl;
	}
    return 0;
}

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

int main()
{
	int n,s[100],max,min,nmax,nmin,ret;
	while (cin >> n, n) {
		for(int i = 0;i < n;i++) {
			cin >> s[i];
		}
		min = 1000;
		max = 0;
		for (int i = 0; i < n; i++) {
			if (s[i] > max){
				max = s[i];
				nmax = i;
			}
			if (s[i] < min) {
				min = s[i];
				nmin = i;
			}
		}
		s[nmax] = s[nmin] = 0;
		ret = 0;
		for (int i = 0; i < n; i++) {
			ret += s[i];
		}
		cout << ret / (n - 2) << endl;
	}
	return 0;
}