#include <bits/stdc++.h>
# define M_PI           3.14159265358979323846  /* pi */
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	int count = 0;
	int result = 200;

	for (int i = 0; i < N; i++) {
		cin >> A.at(i);

		while (true) {
			if (A.at(i) % 2 != 0 || A.at(i) == 0) {
				break;
			}

			else if (A.at(i) % 2 == 0) {
				A.at(i) = A.at(i) / 2;
				count++;
			}
		}

		result = min(result, count);
		count = 0;
	}

	cout << result << endl;
}
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <climits>
#include <utility>

#define PRINT(STR) cout << STR << endl;
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()

typedef long long ll;

using namespace std;

int nextInt() { int n = -1; cin >> n; return n; }
double nextDouble() { double d = -1; cin >> d; return d; }
ll nextll() { ll n = -1; cin >> n; return n; }
string nextString() { string str; cin >> str; return str; }

int INF = 1LL << 25;
double EPS = 1e-9;

// BEGIN //////////////////////////////////////////////////////////////

int main() {
	while (true) {
		int N = nextInt();
		if (N == 0) break;
		int score_max = -INF, score = 0;
		REP(i, N) {
			int d = nextInt();
			score += d;
			score_max = max(score, score_max);
			score = max(score, 0);
		}
		PRINT(score_max);
	}

	return 0;
}

// END   //////////////////////////////////////////////////////////////