//by kcz 1552920354@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
using namespace std;

template <typename T> void chmin(T &x,const T &y)
{
	if(x>y)x=y;
}
template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define pb push_back
#define mp make_pair
#define gc (c=getchar())
char readc()
{
	char c;
	while(gc<'-');
	return c;
}
int read()
{
    char c;
    while(gc<'-');
    if(c=='-')
    {
        int x=gc-'0';
        while(gc>='0')x=x*10+c-'0';
        return -x;
    }
    int x=c-'0';
    while(gc>='0')x=x*10+c-'0';
    return x;
}
#undef gc

const int N=100+5;
int a[N],cnt[N];
int n,L,L2;

ll ans;
void dfs(int x,ll s)
{
	if(x>L)
	{
		rep(i,L+1,L2)
		if(!cnt[i])
		{
			if(!cnt[i*2])
			{
				if(a[i]+a[i*2]<0)s-=a[i]+a[i*2];
			}
			else
			{
				if(a[i]<0)s-=a[i];
			}
		}
		chmax(ans,s);
		return ;
	}
	dfs(x+1,s);
	if(cnt[x])return ;
	for(int y=x;y<=n;y+=x)
	if(++cnt[y]==1)s-=a[y];
	dfs(x+1,s);
	for(int y=x;y<=n;y+=x)--cnt[y];
}

int main()
{
	//freopen("1.in","r",stdin);//freopen("1.out","w",stdout);
	cin>>n;
	rep(i,1,n)cin>>a[i];
	n=100;
	L=n/3;L2=n/2;
	rep(i,L2+1,n)
	if(a[i]<0)a[i]=0;
	
	ll s=0;
	rep(i,1,n)s+=a[i];
	ans=s;
	dfs(1,s);
	cout<<ans<<endl;
}
