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 <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 <bits/stdc++.h>
using namespace std;
int n;
int s[100];

int main() {
    while(true) {
        scanf("%d", &n);
        if (n == 0) break;
        for (int i=0; i<n; i++) scanf("%d", &s[i]);
        sort(s, s+n);
        int sum = 0;
        for (int i=1; i<n-1; i++) sum += s[i];
        printf("%d\n", sum / (n - 2));
    }
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <tuple>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

typedef long long LL;

//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 DECIM8  fixed<<setprecision(8) 
#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())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    int sum=0,M=0,m=0;
    REP(i,n){
      int tmp;
      cin >> tmp;
      sum+=tmp;
      if(M<tmp) M=tmp;
      if(m>tmp) m=tmp;
    }
    cout << (sum-M-m)/(n-2) << endl;
  }
}

C++: #include<iostream>
#include<algorithm>
int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int n;
	int avg=0;
	int s[100];
	while (true){
		std::cin >> n;
		if (n == 0) break;
		int q = n - 2;
		for (int i = 0; i < n; i++){
			std::cin >> s[i];
		}
		std::sort(s, s + n);
		for (int i = 1; i <= n-2; i++){
			avg += s[i];
			s[i-1] = 0;
			s[i] = 0;
		}
		std::cout << avg /q << "\n";
		int avg = 0;
		
	}
}

C++: #include <iostream>

#include <algorithm>
#include <numeric>

#include <vector>
#include <queue>
#include <stack>
#include <map>

#define FOR(i,b,e) for(int i=b;i<e;i++)
#define REP(i,n) FOR(i,0,n)

using namespace std;

typedef pair<int, int> P;

const int MAX_N = 100;
int n;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  while (true) {
    vector<int> scores;

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

    REP(i,n) {
      int s;
      cin >> s;
      scores.push_back(s);
    }

    sort(scores.begin(), scores.end());
    int sum = accumulate(scores.begin() + 1, scores.end() - 1, 0);

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

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n1;
	cin >> n1;
		int a[100000] = { 0 };
		for (int i = 0; i < n1; i++){
			cin >> a[i];
		}
		sort(a, a + n1);
		a[0] = { 0 };
		a[n1 - 1] = { 0 };
		for (int i2 = 1; i2 < n1; i2++){
			a[0] += a[i2];
		}
		cout << a[0] / (n1 - 2) << endl;
		return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
	int n;
	while(cin >> n, n){
		vector<int> v(n);
		int ma = -1, mi = inf;
		bool a = true, b = true;
		for(int i=0; i < n; i++){
			cin >> v[i];
			if(ma < v[i]) ma = v[i];
			if(v[i] < mi) mi = v[i];
		}
		int sum = 0;
		rep(i, v.size()){
			if(ma == v[i] && a){a = false; continue;}
			if(mi == v[i] && b){b = false; continue;}

			sum += v[i];
		}
		cout << sum/(v.size()-2) << endl;
	}
}

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    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 <bits/stdc++.h>

int main()
{
	while (true)
	{
		int n;
		scanf("%d", &n);
		if (!n) break;
		
		std::vector<int> points(n);
		for (auto& e: points) scanf("%d", &e);
		std::sort(points.begin(), points.end());
		int sum{};
		for (int i{1}; i < n - 1; i++)
			sum += points[i];
		printf("%d\n", sum / (n - 2));
	}

	return 0;
}

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

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

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;
    sum += s;
    max = s;
    cin >> s;
    sum += s;
    if(max < s){
      max = s;
    }else{
      min = s;
    }
    for(int i = 2; i < n; i++){
      cin >> s;
      sum += s;
      if(max < s){
	max = s;
      }else if(min > s){
	min = s;
      }
    }
    sum -= max;
    sum -= min;
    int ave = sum / (n-2);

    cout << ave << endl;
  }

  return 0;
}

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

int main(){
	int n, s, sum, maxs, mins, i;
	while((cin >> n), n){
		sum = maxs = 0;
		mins = 1000;
		for(i = 0; i < n; i++){
			cin >> s;
			sum += s;
			maxs = max(maxs, s);
			mins = min(mins, s);
		}
		sum = (sum - maxs - mins) / n;
		cout << sum << endl;
	}
}

C++: // ACM-ICPCà\I2007 A. ICPC ¾_Wv\tgEFA

#include <iostream>
#include <vector>

using namespace std;

int main(){
	int n;
	while(cin >> n, n){
		if(n==0) break;
		int m = 9999999, M = 0, sum = 0;
		for(int i=0;i<n;i++){
			int tmp; cin >> tmp;
			m = min(m,tmp);
			M = max(M,tmp);
			sum += tmp;
		}
		cout << (sum-m-M)/(n-2) << endl;
	}
}

C++: #include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<random>
#include<string>
typedef long long ll;
using namespace std;
int main(){
  ll N;
  ll s[1100];
  ll sum=0;
  ll t=0;
  while(t<=20){
  t++;
  cin >> N;
  for(ll i = 0; i < N; ++i){
      cin >> s[i];
  }
  sort(s,s+N);
  for(ll i = 1; i < N-1; ++i){
    sum+=s[i];
  }
  cout<<sum/(N-2)<<endl;
}
}