#include <iostream>
using namespace std;
typedef long long ll;
ll n, mx, a[105];

void f(ll p) {
	ll i, s, b[105];
	if(p==n+1) {
		s = 0;
		for(i=1; i<=n; i++) s += a[i];
		mx = max(mx, s);
		return;
	}
	if(a[p]<0) {
		for(i=1; i<=n; i++) b[i] = a[i];
		for(i=p; i<=n; i+=p) a[i] = 0;
		f(p+1);
		for(i=1; i<=n; i++) a[i] = b[i];
	}
	f(p+1);
}

int main() {
	ll i, j, s;
	cin>>n;
	for(i=1; i<=n; i++) cin>>a[i];
	for(i=n; i>n/6; i--) {
		s = 0;
		for(j=i; j<=n; j+=i) s += a[j];
		if(s<=0) for(j=i; j<=n; j+=i) a[j] = 0;;
	}
	f(1);
	cout<<mx;
}