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

int a[101];

int main(){
	int n;
	while( cin >> n, n ){
		for(int i=0 ; i < n ; i++ )
			cin >> a[i];
		int mx, mn;
		mx = mn = a[0];
		for(int i=1 ; i < n ; i++ ){
			mx = max( mx , a[i] );
			mn = min( mn , a[i] );
		}
		int s = 0;
		for(int i=0 ; i < n ; i++ ){
			if( a[i] == mn ){
				a[i] = 0;
				break;
			}
		}
		for(int i=0 ; i < n ; i++ ){
			if( a[i] == mx ){
				a[i] = 0;
				break;
			}
		}
		for(int i=0 ; i < n ; i++ ){
			s += a[i];
		}
		cout << s/(n-2) << endl;
	}
}

C++: #include<iostream>
using namespace std;
 
int main(){
    int n,i;
    while(cin >> n,n){
        //int point[100]={0,};
		int p;
        int min = 1000;
        int max = 0;
		int total = 0;
        while(n--){
            //cin >> point[i];
			cin >> p;
            //if(point[i] > max) max = point[i];
			if(p > max) max = p;
            //if(point[i] < min) min = point[i];
			//total += point[i];
			if(p < min) min = p;
        }
        cout << (total-max-min)/(n-2) << "\n";
    }

}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int a,b[100];
  while(1)
  {
    scanf("%d",&a );
    if(a == 0)
    {
      break;
    }

    for(int i=0; i<a; i++)
    {
      scanf("%d",&b[i] );
    }

    sort(b,b+a);

    int c = 0;
    for(int i=1; i < a-1; i++)
    {
      c+=b[i];
    }
    printf("%d\n",c / (a-2) );
  }
}

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


int main(){
  int n = 0;
  while(1){
    cin >> n;
    if(n == 0) break;
    vector<int> score(n);
    for(int i = 0; i < n; i++){
      cin >> score[i];
    }

    sort(score.begin(), score.end());
    int sum = 0;
    for(int i = 1; i < n - 1; i++){
      sum += score[i];
    }
    cout << sum / (n - 2) << endl;
  }
  return 0;
}

C++: #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
template<class T> using vv=vector<vector<T> >;

int main() {
  vector<int> results;

  while (true) {
    int count;
    cin >> count;
    if (count == 0) { break; }
    vi point(count);
    for (int i = 0 ; i < count ; i++) {
      cin >> point[i];
    }
    //sort(point.begin(), point.end());
    int max_point = -1;
    int min_point = 1001;
    int ave = 0;
    for (int i = 0 ; i <= point.size()-1 ; i++) {
      ave += point[i];
      if (max_point < point[i]) {
        max_point = point[i];
      }
      if (min_point > point[i]) {
        min_point = point[i];
      }
    }
    ave -= (max_point + min_point);
    ave /= (count-2);
    results.push_back(ave);
  }

  for (int i = 0 ; i < results.size() ; i++) {
    printf("%d\n", results[i]);
  }

  return 0;
}

C++: #include <bits/stdc++.h>
#include <iterator>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(v) begin(v), end(v)
#define rreps(i, a, n) for (ll i = (a); i <= (ll)(n); ++i)
#define rrep(i, n) rreps(i, 0, n)
#define reps(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) reps(i, 0, n)
#define each(i, n) for (auto&& i : n)
#define fill(x, y) memset(x,y,sizeof(x))
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <typename T> inline void print(const T& x) {cout << x << '\n';}

signed main()
{ 
  int n;
  vi ans;
  while(cin>>n, n)
  {
    vi s(n);
    each(v,s) cin>>v;
    sort(ALL(s));
    s.pop_back();
    s.erase(s.begin());
    int sum=0;
    rep(i,s.size()) sum+=s[i];
    ans.push_back(sum/s.size());
  }
  each(v,ans) print(v);

  return 0;
}

C++: #include "algorithm"
#include "iostream"
#include "cmath"
#include "string"
#include "map"
using namespace std;


int main(){
  while(true){
  int n,min=1001,max=-1,sum=0,ten;
  cin >> n;
  if(!n)break;
  for(int i =0;i<n;i++){
    cin >> ten;
    sum+=ten;
    if(min>ten)min=ten;
    if(max<ten)max=ten;
  }
  cout << (sum-min-max)/(n-2) <<endl;
}
  return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <ctype.h>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;


int main (){

  while(1){
    vector<int> point;
    int n,i,temp,sum;
    cin >> n;
    if (n==0)break;
    
    for(i=0;i<n;i++){
      cin >> temp;
      point.push_back(temp);
    }
    
    sort(point.begin(),point.end());
    
    sum = 0;
    
    for(i=1;i<n-1;i++){
      sum += point[i];
    }
    
    sum = sum / (n-2);
    
    cout << sum <<endl;
  }
  
  return 0;
}

C++: #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

#define Rep(b, e, i) for (int i = b; i <= e; i++)
#define Repr(e, b, i) for (int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n - 1, i)
#define repr(n, i) Repr(n - 1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)), (x).end())

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1 << 31 - 1;
const int MOD = 1000000007;

void solve(void) {
  while (1) {
    int N;
    scanf("%d\n", &N);
    if (N == 0)
      break;
    vector<int> ps;
    rep(N, i) {
      int p;
      scanf("%d\n", &p);
      ps.pb(p);
    }
    sort(all(ps));
    int ans = ps[0] + ps[N - 1];
    for (int t : ps) {
      if (t != ps[0] && t != ps[N-1]) ans += t;
    }
    printf("%d\n", ans / N);
  }
}

int main(void) {
  solve();
  return 0;
}

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

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

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<string>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define INF 1145141919810893931
using namespace std;

int main() {
	ll n; cin >> n;
	while (n) {
		vector<ll> a(n);
		vector<ll> b(n - 2);
		rep(i, n) cin >> a[i];
		sort(a.begin(), a.end());
		ll b_count = 0;
		nrep(i, 1, n - 1) b[b_count++] = a[i];
		ll sum = 0;
		rep(i, b.size()) sum += b[i];
		cout << sum / b.size() << endl;
		cin >> n;
	}
	return 0;
}