#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<functional>
#include<vector>
#include<queue>
using namespace std;
#define f(i,n) for(int i=0;i<(int)n;i++)
#define MOD 1000000009

int main(void){
	long long a[101];
	f(i, 101)a[i] = 0;
	bool b[101];
	f(i, 101)b[i] = false;
	long long s;
	int n, m;
	int x, y;
	bool z = true;
	long long ans = 0;
	long long mx = 0;
	int cnt;

	scanf("%d ", &n);
	f(i, n){
		scanf("%lld", &a[i + 1]);
	}
	for (int kk =0; kk < 4194304; kk++){
		x = kk;
		for (int i = 1; i <= n; i++)b[i] = true;
		z = true;
		for (int i = 1; i <=22; i++){
			if (x % 2 == 0){
				if (b[i] == false){
					z = false;
					break;
				}
				for (int j = 1; j*i <= n; j++){
					b[i*j] = false;
				}
			}
			x = x / 2;
		}
		x = 0;
		while (z){
			cnt = 0;
			if (x == 0){
				for (int i = n; i >= 23; i--){
					s = 0;
					for (int j = 1; j*i <= n; j++){
						if (b[i*j] == true)s += a[i*j];
					}
					if (s < 0){
						for (int j = 1; j*i <= n; j++){
							b[i*j] = false;
						}
						cnt++;
					}
				}
			}
			else{
				for (int i = n/2; i >= 23; i--){
					s = 0;
					for (int j = 1; j*i <= n; j++){
						if (b[i*j] == true)s += a[i*j];
					}
					if (s < 0){
						for (int j = 1; j*i <= n; j++){
							b[i*j] = false;
						}
						cnt++;
					}
				}
			}
			if (cnt == 0)z = false;
			x = 1;
		}
		ans = 0;
		for (int i = 1; i <= n; i++){
			if (b[i] == true)ans += a[i];
		}
		mx = max(mx, ans);
	}
	printf("%lld\n", mx);

	return 0;
}