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 <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

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

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

int main() {
	int n;
	while(cin >> n, n) {
		int a = 1001;
		int b = -1;
		int sum = 0;
		for(int i = 0; i < n; ++i) {
			int t;
			cin >> t;
			sum += t;
			a = min(a, t);
			b = max(b, t);
		}
		
		sum -= a + b;
		
		cout << sum / (n - 2) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	
	int n;

	while(cin>>n){
		int s=0;
		if(n!=0){
			vector<int> a(n);
			for(int i=0;i<n;i++)
				cin>>a[i];
			sort(a.begin(),a.end());
			a[0]=0;
			a[n-1]=0;
			for(int i=0;i<n;i++)
				s+=a[i];
			cout<<s/(n-2)<<endl;
		}
		else
			break;
	}
	
}

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

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


  return 0;
}

C++: 
#include<cstdio>
#include<iostream>
#include<string>
#include <algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
using namespace std;
using ll = long long;



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

}

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

int main(void){
    int n, tmp;
    int ans = 0;
    while(cin >> n && n) {
        vector<int> in;
        for(int i=0; i<n; ++i) {
            cin >> tmp;
            in.push_back(tmp);
        }
        sort(in.begin(), in.end());
        for(int i=1; i<n-1; ++i) ans += in[i];
        cout << ans/(n-2) << endl;
    }
}

C++: #include<algorithm>
#include<iostream>
#define rep(i,a) for(int i=0;i<(a);++i)

int n;

int main()
{
	while( std::cin >> n, n )
	{
		int ma = 0, mi = 1001, S = 0;
	
		rep( i, n )
		{
			int a;
			std::cin >> a;
			ma = std::max( ma, a );
			mi = std::min( mi, a );
			S += a;		
		}
		
		std::cout << (S-ma-mi)/(n-2) << std::endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
#define ll long long
#define INF 1000000000
using namespace std;
int main(){
    int N;
    int s;
    int smax,smin;
    int sum;
    while(1){
        cin >> N;
        if(N==0) return 0;
        smax = 0; smin = INF; sum = 0;
        for(int i=0;i<N;i++){
            cin >> s;
            smax = max(smax,s);
            smin = min(smin,s);
            sum += s;
        }
        sum = sum - smax - smin;
        int ans = sum/(N-2);
        cout << ans << endl;
    }
}

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

int main() {
    int N;
    while (cin >> N, N) {
        vector<int> v(N);
        for (auto& i : v) cin >> i;
        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 <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <random>


// boost
#define USE_BOOST_IN_CODE
#ifdef USE_BOOST_IN_CODE
#include <boost/range.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/strided.hpp>
#include <boost/range/adaptor/transformed.hpp>
#include <boost/format.hpp>
#endif


using ll = long long;

//vector
template <class T>
using vec = std::vector<T>;

//namespace std
//{
//    template<>
//    class hash<Key>
//    {
//    public:
//        size_t operator() (const Key& key) const
//        {
//            size_t seed = 0;
//            auto i_hash = hash<int>()(key.i_th);
//            auto w_hash = hash<int>()(key.W);
//
//            seed ^= i_hash + 0x9e3779b9 + (seed << 6) + (seed >> 2);
//            seed ^= w_hash + 0x9e3779b9 + (seed << 6) + (seed >> 2);
//
//            return seed;
//        }
//    };
//}

void solve()
{
    using namespace std;

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

        vec<int> v(n);
        for (auto& x : v)
            cin >> x;

        boost::sort(v);

        cout << accumulate(v.cbegin() + 1, v.cend() - 1, 0) / (n - 2) << endl;
        ++count;
    }

}

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

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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define reps(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) reps(i, 0, n)
#define REPS(i, a, b) reps(i, a, b)
#define REP(i, n) rep(i, n)
#define deps(i, a, b) for (int i = a; i >= b; --i)
#define dep(i, n) deps(i, n, 0)
#define DEPS(i, a, b) deps(i, a, b)
#define DEP(i, n) dep(i, n)

#define pf push_front
#define pb push_back
#define mp make_pair
#define fst first
#define FST fst
#define sec second
#define SEC sec
#define sz(obj) ((int)(obj).size())
#define all(v) (v).begin(), (v).end()
#define ALL(v) all(v)

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T> void print(T x) { std::cout << x << '\n'; }

signed main()
{
  while (int n = in(), n){
    vi v;
    int sum = 0;

    rep(i, n) v.pb(in());
    sort(all(v));
    for (int i = 1; i < n - 1; i++) sum += v[i];
    print(sum / (n - 2));
  }

  return (0);
}

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

int main(){
    int n;

    while(true){
        std::cin >> n;
        if(n == 0) break;

        int* x = new int[n];

        for(int i=0; i<n; i++){
            std::cin >> x[i];
        }

        std::sort(x, x+n);
        int sum = 0;
        for(int i=1; i<(n-1); i++){
            sum += x[i];
        }

        std::cout << sum/(n-2) << std::endl;

        delete[] x;
    }

    return 0;
}

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

using namespace std;

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

}