#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e2+11;
const ll INF=1e18+11;
struct Edge{int nxt,to;ll cap,flow;}edge[N*N*2];
int num_edge=1,n,cur[N],head[N],d[N],s,t;
ll ans;
bool vis[N];
void add_edge(int from,int to,ll cap){
	edge[++num_edge].nxt=head[from];edge[num_edge].to=to;edge[num_edge].cap=cap;edge[num_edge].flow=0;head[from]=num_edge;
	edge[++num_edge].nxt=head[to];edge[num_edge].to=from;edge[num_edge].cap=0;edge[num_edge].flow=0;head[to]=num_edge;
}
bool bfs(){
	memset(vis,0,sizeof(vis));
	queue<int> Q;
	Q.push(s);vis[s]=1;
	while(!Q.empty()){
		int u=Q.front();Q.pop();
		for(int i=head[u];i;i=edge[i].nxt){
			int v=edge[i].to;
			if(!vis[v]&&edge[i].cap>edge[i].flow){
				d[v]=d[u]+1;
				vis[v]=1;
				Q.push(v);
			}
		}
	}
	return vis[t];
}
ll dfs(int u,ll a){
	if(a==0||u==t) return a;
	ll flow=0,f;
	for(int &i=cur[u];i;i=edge[i].nxt){
		int v=edge[i].to;
		if(d[v]==d[u]+1&&(f=dfs(v,min(a,edge[i].cap-edge[i].flow)))>0){
			flow+=f;
			edge[i].flow+=f;
			edge[i^1].flow-=f;
			a-=f;
			if(!a) break;
		}
	}
	return flow;
}
ll dinic(){
	ll ret=0;
	while(bfs()){
		for(int i=0;i<=t;++i) cur[i]=head[i];
		ret+=dfs(s,INF);
	}
	return ret;
}
int main(){
//	freopen("ex.in","r",stdin);
	scanf("%d",&n);t=n+1;
	for(int i=1;i<=n;++i){
		ll a;
		scanf("%lld",&a);
		if(a<=0) add_edge(s,i,-a);
		else add_edge(i,t,a),ans+=a;
	}
	for(int i=1;i<=n;++i){
		for(int j=2*i;j<=n;j+=i){
			add_edge(i,j,INF);
		}
	}
	ans-=dinic();
	printf("%lld",ans);
	return 0;
}