#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <set>
using namespace std;

typedef pair<int,int> PII;

int F, c[100005];
int gcdall;
vector<PII> fact;
vector<long long> v;
set<long long> st;

int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a;
}

int main() {
	while (scanf("%d", &F) == 1 && F) {
		for (int i = 1; i <= F; ++i)
			scanf("%d", c+i);
		gcdall = c[1];
		for (int i = 2; i <= F; ++i) {
			gcdall = gcd(gcdall, c[i]);
		}
		v.clear(); st.clear(); fact.clear();
		v.push_back(1); st.insert(1);
		for (int i = 2; i * i <= gcdall; ++i) {
			int p = 0;
			while (gcdall % i == 0) {
				gcdall /= i; ++p;
			}
			if (p) fact.push_back(PII(i, p));
		}
		if (gcdall > 1) fact.push_back(PII(gcdall,1));
		for (int i = 0; i < fact.size(); ++i) {
			int p = fact[i].first;
			//long long pj = 1;
			//printf("fact: %d %d\n",fact[i].first,fact[i].second);
			for (int j = 0; j < fact[i].second; ++j) {
				//pj *= p;
				//printf("pj=%lld\n",pj);
				int len = v.size();
				//printf("size of v:%d\n",v.size());
				for (int k = 0; k < len; ++k) {
					//printf("v[k] = %lld\n", v[k]);
					long long z = v[k] * p;
					if (!st.count(z)) {
						st.insert(z); v.push_back(z);
						//printf("%lld ",z);
						assert(z!=0);
					}
				}
			}
		}
		//printf("size of v:%d\n",v.size());
		long long ans = 0;
		for (int vi = 0; vi < v.size(); ++vi) {
			//printf("now v = %lld\n", v[vi]);
			int k = v[vi];
			//printf("vi=%d\n",k);
			//assert(k!=0);
			int yUP = 1 << 30, A = -1;
			for (int i = 1; i <= F; ++i) {
				yUP = min(yUP, c[i]/k - F);
				int z = (c[i]/k) % F;
				if (A < 0) A = z;
				if (A != z) { A = -1; break; }
			}
			if (A >= 0 && yUP >= 1) {
				ans += (yUP - A) / F + 1;
				if (A == 0) --ans;
			}
			//printf("k=%d A=%d yUP=%d ans = %lld\n",k,A,yUP,ans);
		}
		printf("%lld\n", ans);
	}
	return 0;
}
