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<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
const int INF = 1e9;


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

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

#define repeat(i, n) for(int i=0; i < (n); i++) 

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        vector<int> scores;
        repeat(i, n) {
            int s; cin >> s;
            scores.push_back(s);
        }
        int max_s, min_s;
        max_s = *max_element(scores.begin(), scores.end());
        min_s = *min_element(scores.begin(), scores.end());
        int sum = -max_s-min_s;
        repeat(i, n) {
            sum += scores[i];
        }
        int average = sum / (n-2);
        cout << average << endl;
    }
    return 0;
}

C++: #include<iostream>

using namespace std;

int main () {

  while (true){

    int n;
    int i;
    int s = 0;
    int mi = 0;
    int ma = 0;
    cin >> n;

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

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

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

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

      s += p[i];

    }

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

  }

  return 0;

}

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

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

  int sum = 0, x, total, ans;
  vector<int> p(0);
  int n;
  
    while(1){
      cin >> n;
      if(n==0)
      break;
      for(int i=0; i<n; i++){
        cin >> x;
        p.push_back(x);
      }

      int max = *max_element(p.begin(), p.end());
      int min = *min_element(p.begin(), p.end());

      for(int i=0; i<n; i++){
        sum += p[i];
      }
      total = sum - min - max;
      ans = total / (n-2);
      cout << ans << endl;
    } 

  return 0;
}

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

int n,s[100];
int temp,ave,sum;

void sort(void){
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      if(s[i]>s[j]){
	temp=s[i];
	s[i]=s[j];
	s[j]=temp;
      }
    }
  }
}

int main(){
  while(cin >> n,n){
    for(int i=0;i<n;i++)
      cin >> s[i];  
    
    sort();
    
    sum=0;

    for(int i=0;i<n-2;i++)
      sum+=s[i+1];

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

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

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

  }
}

C++: #include <iostream>
#include <cstdio>
#include <iomanip>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>

#include <numeric>
#include <algorithm>
#include <functional>

#include <cctype>

#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(unsigned int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)

typedef long long ll;
typedef complex<double> P;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};
const double EPS = 1e-9;
const int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

int main(){
    while(true){
        int n;
        cin >> n;
        if(n==0) break;
        vector<int> S(n);
        rep(i,n) cin >> S[i];
        int total = accumulate(all(S),0) - *max_element(all(S)) - *min_element(all(S));
        double ave = total / (S.size()-2);
        int iave = floor(ave);
        cout << iave << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int main()
{
    int i,j,in[100],hum,ans,mx=0,mn=1000;
    for(;scanf("%d",&hum),hum!=0;)
    {
        for(i=0,mx=0,mn=1000,ans=0;i<hum;i++)
        {
            scanf("%d",&in[i]);
            mx=mx<in[i]?in[i]:mx;
            mn=mn>in[i]?in[i]:mn;
            ans+=in[i];
        }
        ans=ans-(mn+mx);
        printf("%d\n",ans/(hum-2));
    }
    return 0;
}

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

int main(){

  while(1){
    int n;
    int p[200];
    cin >> n;

    if(n == 0) break;
    int max = -1,min = 2000;
    for(int i = 0;i< n;i++){
      cin >> p[i];
      if(max < p[i])max = p[i];
      if(min > p[i])min = p[i];
    }

    int sum = 0,count=0;
    for(int i = 0;i< n;i++){
      if(p[i] != max && p[i] != min){
	sum += p[i];
	count++;
      }
    }
    cout << sum / count << endl;;

  }
  return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	for(int n; cin >> n, n;) {
		vector<int> v(n);
		rep(i,n) cin >> v[i];
		cout << (accumulate(all(v), 0) - *max_element(all(v)) - *min_element(all(v))) / (n - 2) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

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

}

C++: #include <iostream>
using namespace std;
int main(){
  int n,mx,mn;

  while( cin>>n && n ){
    int sum=0;
    mx = -1;
    mn = 10000;
    for( int i=0,j;i<n;i++ ){
      cin >> j;
      sum +=j;
      if( j>mx ) mx=j;
      if( j<mn ) mn =j;
    }

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