#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define PI 3.141592653589793238462643L
int K[100000];
long double SIN(long double b) { return sinl(b * PI / 180.0L); }
int main() {
	int N, cnt = 0; long double a, sum, V; vector<long double, int>vec;
	while (true) {
		cin >> N; V = 0.0L; sum = 0.0L; if (N == 0) { break; }
		for (int i = 0; i < N; i++) { cin >> a; sum += SIN(a); V += a; }
		sum += sin(360.0L - V); vec.push_back(make_pair(sum, cnt)); cnt++;
	}
	sort(vec.begin(), vec.end());
	for (int i = 0; i < cnt; i++) { K[vec[i].second] = i; }
	for (int i = 0; i < cnt; i++) { cout << K[i] << endl; }
	return 0;
}