#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define pb push_back
#define fr first
#define sc second

const int p[21] = { 3,9,15,21,5,7,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32 };
//const int q[4] = { 13,14,15,16 };

int main(){
	int N;
	ll a[102] = {};
	scanf("%d",&N);
	for(int i = 1 ; i <= N ; i ++){
		scanf("%lld",&a[i]);
	}
	for(int i = N/2+1 ; i <= N ; i ++){
		a[i] = max( a[i] , 0LL );
	}
	
	ll ret = 0;
	for(int s = 0 ; s < (1<<21) ; ++s){
		ll A[102];
		for(int i = 1 ; i <= N ; ++i){
			A[i] = a[i];
		}
		for(int i = 0 ; i < 21 ; ++i){
			if((s>>i)&1){
				for(int j = p[i] ; j <= N ; j += p[i]){
					A[j] = 0;
				}
			}
		}
		
		for(int i = N/2 ; i >= 1 ; --i){
			ll sum = 0;
			for(int j = i ; j <= N ; j += i){
				sum += A[j];
			}
			if(i == 1){
				ret = max( ret , sum );
				break;
			}
			if(sum < 0){
				for(int j = i ; j <= N ; j += i){
					A[j] = 0;
				}
			}
		}
	}
	for(int i = 2 ; i <= N ; i += 2){
		a[i] = 0;
	}
	for(int s = 0 ; s < (1<<6) ; ++s){
		ll A[102];
		for(int i = 1 ; i <= N ; ++i){
			A[i] = a[i];
		}
		for(int i = 0 ; i < 6 ; ++i){
			if((s>>i)&1){
				for(int j = p[i] ; j <= N ; j += p[i]){
					A[j] = 0;
				}
			}
		}
		
		for(int i = N/2 ; i >= 1 ; --i){
			ll sum = 0;
			for(int j = i ; j <= N ; j += i){
				sum += A[j];
			}
			if(i == 1){
				ret = max( ret , sum );
				break;
			}
			if(sum < 0){
				for(int j = i ; j <= N ; j += i){
					A[j] = 0;
				}
			}
		}
	}
	cout << ret << endl;
}

