Go: package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	for n != 0 {
		arr := make([]int, n)
		for i := range arr {
			fmt.Scan(&arr[i])
		}
		sort.Ints(arr)

		sum := 0
		for i := 1; i < len(arr)-1; i++ {
			sum += arr[i]
		}
		fmt.Println(sum / (n - 2))
		fmt.Scan(&n)
	}
}

C++: #include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int s[101];

int main(void) {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        int sum = 0;
        int ma = 0, mi = INF;
        for (int i = 0; i < n; i++) {
            cin >> s[i];
            ma = max(ma, s[i]);
            mi = min(mi, s[i]);
            sum += s[i];
        }
        sum -= (ma + mi);
        cout << sum / (n-2) << endl;
    }
    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;
    
    int minimum = 1e3, maximum = 0, sum = 0;
    for (int i = 0; i < n; i++) {
      int s;
      cin >> s;
      sum += s;
      minimum = min(minimum, s);
      maximum = max(maximum, s);
    }
    
    cout << (sum - minimum - maximum) / (n - 2) << '\n';
  }
}

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

using namespace std;

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

        vector<int> v(n);

        for (int i = 0; i < n; i++) { cin >> v[i]; }
        v.sort(v.begin(), v.end());

        int sum = 0;
        for (int i = 1; i < n-1; i++) {
            sum += v[i];
        }

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

C++: #include<iostream>
#include<cmath>
using namespace std;
int main(){
    int max, min, sum,n,x,ans;
    while(true){
        cin>>n;
        if(n!=0){
            cin>>x;
            max=x;
            min=x;
            sum=x;
            for(int i=1;i<n;i++){
                cin>>x;
                sum+=x;
                if(max<x){
                    max=x;
                }
                if(min>x){
                    min=x;
                }
            }
            ans=(sum-min-max)/(n-2);
            cout<<ans<<endl;
        }else{
            break;
        }
    }
    return 0;
}

C++: #include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  while(N != 0){
    vector<int> A(N);
    rep(i,N){
      cin >> A[i];
    }
    sort(A.begin(),A.end());
    int sum = 0;
    for(int i=1; i<N-1; i++){
      sum += A[i];
    }
    cout << sum/(N-2) << endl;
    cin >> N;
  }
  return 0;
}

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

using namespace std;

int main()
{
    for (;;) {
        int n, s[100];

        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));
    }

    return 0;
}

C++: int maximum = 0;
    for (int i=1; i<S; ++i)
        for (int j=i; j<S; ++j)
            if (tax(X,i)+tax(X,j) == S) // (*)
              maximum = max(maximum, tax(Y,i)+tax(Y,j));

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

int main(){
  int n,s;
  
  while(cin>>n && n!=0){
    int sum=0;
    int largest=0;
    int smallest=1000;
    
    for(int i=1;i<=n;i++){
      cin>>s;
      sum+=s;
      if(largest<s)  largest=s;
      if(smallest>s) smallest=s;
    }
    int result=sum-largest-smallest;

    cout<<(int)(result/(n-2))<<endl;
}

}

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

int main(){
    int n;

    while(cin>>n,n){
        vector<int> v(n);

        for(auto &t:v){
            cin>>t;
        }

        sort(v.begin(),v.end());
        cout << accumulate(v.begin()+1,v.end()-1,0) / (n-2) << endl;
    }
}

C++: #include<cstdio>
#include<cstdlib>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;

int main(){
  int n,min,max,result;
  int score[100];

  while(true){

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

    result = 0;
    min = 1000;
    max = 0;

    REP(i,n){
      int score;
      cin >> score;
      if(max < score) max = score;
      if(min > score) min = score;
      result += score;
    }
    cout << (result - max - min)/(n-2) << endl;
  }
  return 0;
}