// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



#define int long long

const double PI = 3.14159265358979323846;

typedef vector<int> vint;

typedef pair<int, int> pint;

int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};

int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};



const int MAX_V = 110000;

const int INF = 1e14;



struct edge {

    int to, cap, rev;

};



vector<edge> G[MAX_V];

bool used[MAX_V];



void add_edge(int from, int to, int cap) {

    G[from].push_back((edge) {to, cap, G[to].size()});

    G[to].push_back((edge) {from, 0, G[from].size() - 1});

}



int dfs(int v, int t, int f) {

    if (v == t) {

        return f;

    }

    used[v] = true;

    for (int i = 0; i < G[v].size(); i++) {

        edge &e = G[v][i];

        if (!used[e.to] && e.cap > 0) {

            int d = dfs(e.to, t, min(f, e.cap));

            if (d > 0) {

                e.cap -= d;

                G[e.to][e.rev].cap += d;

                return d;

            }

        }

    }

    return 0;

}



int max_flow(int s, int t) {

    int flow = 0;

    for (;; ) {

        memset(used, 0, sizeof(used));

        int f = dfs(s, t, INF);

        if (f == 0) {

            return flow;

        }

        flow += f;

    }

}



int N;

int a[110];



signed main() {

    cin >> N;

    for (int i = 1; i <= N; i++) cin >> a[i];



    for (int i = 1; i <= N; i++) {

        add_edge(0, i, INF - a[i]);

        add_edge(i, 101, INF);

        for (int j = 2 * i; j <= N; j += i) add_edge(i, j, INF);

    }

    cout << INF*N - max_flow(0, 101);



}


// Faster C++ solution for the same problem (measured speedup: 3.901891139854841x):
#include<bits/stdc++.h>

using namespace std;



#define int long long

#define double long double

#define rep(i, n) for (int i = 0; i < (n); i++)

#define reps(i, n) for (int i = 1; i <= (n); i++)

#define all(x) (x).begin(), (x).end()

#define uniq(x) (x).erase(unique(all(x)), (x).end())

#define bit(n) (1LL << (n))

#define dump(x) cerr << #x " = " << (x) << endl

using vint=vector<int>;

using vvint=vector<vint>;

using pint=pair<int, int>;

using vpint=vector<pint>;

template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;

constexpr double pi = 3.1415926535897932384626433832795028;

constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};

int gcd(int a, int b) {

    while (b) { swap(a %= b, b); }

    return a;

}

int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {

    if (a < b) {

        a = b;

        return true;

    }

    return false;

}

template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {

    if (b < a) {

        a = b;

        return true;

    }

    return false;

}

template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {

    os << "(" << rhs.first << ", " << rhs.second << ")";

    return os;

}

template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {

    os << "{";

    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {

        os << *itr << (next(itr) != rhs.end() ? ", " : "");

    }

    os << "}";

    return os;

}

struct Setup {

    static constexpr int PREC = 20;

    Setup() {

        cout << fixed << setprecision(PREC);

        cerr << fixed << setprecision(PREC);

    };

} setup;



template<typename T>

struct Dinic {

    struct edge {

        int to, rev;

        T cap;

        bool isRev;

    };

    int n;

    T ZERO, INF;

    std::vector<std::vector<edge>> G;

    std::vector<int> level, iter;

    Dinic(int n, T INF = std::numeric_limits<T>::max(), T ZERO = T())

        : n(n), INF(INF), ZERO(ZERO), G(n), level(n), iter(n) {}

    void addEdge(int from, int to, T cap) {

        G[from].push_back({to, (int) G[to].size(), cap, false});

        G[to].push_back({from, (int) G[from].size() - 1, ZERO, true});

    }

    void bfs(int s) {

        fill(level.begin(), level.end(), -1);

        std::queue<int> que;

        level[s] = 0;

        que.push(s);

        while (!que.empty()) {

            int v = que.front();

            que.pop();

            for (int i = 0; i < G[v].size(); i++) {

                edge &e = G[v][i];

                if (e.cap > ZERO && level[e.to] < 0) {

                    level[e.to] = level[v] + 1;

                    que.push(e.to);

                }

            }

        }

    }

    T dfs(int v, int t, T f) {

        if (v == t) { return f; }

        for (int &i = iter[v]; i < G[v].size(); i++) {

            edge &e = G[v][i];

            if (level[v] < level[e.to] && e.cap > ZERO) {

                T d = dfs(e.to, t, std::min(f, e.cap));

                if (d > ZERO) {

                    e.cap -= d;

                    G[e.to][e.rev].cap += d;

                    return d;

                }

            }

        }

        return ZERO;

    }

    T calcMaxFlow(int s, int t, T lim) {

        T flow = ZERO;

        while (true) {

            bfs(s);

            if (level[t] < 0 || lim == ZERO) { return flow; }

            fill(iter.begin(), iter.end(), 0);

            T f;

            while ((f = dfs(s, t, lim)) > ZERO) {

                flow += f;

                lim -= f;

            }

        }

    }

    T calcMaxFlow(int s, int t) { return calcMaxFlow(s, t, INF); }

    std::map<std::pair<int, int>, T> getMaxFlow() {

        std::map<std::pair<int, int>, T> ret;

        for (int i = 0; i < n; i++) {

            for (int j = 0; j < G[i].size(); j++) {

                edge &e = G[i][j];

                if (e.isRev) { ret[{e.to, i}] = e.cap; }

            }

        }

        return ret;

    }

    std::map<std::pair<int, int>, T> getMinCut(int s) {

        std::map<std::pair<int, int>, T> ret;

        std::vector<int> visited(n);

        std::queue<int> que;

        que.push(s);

        while (!que.empty()) {

            int v = que.front();

            que.pop();

            if (visited[v]) { continue; }

            visited[v] = true;

            for (int i = 0; i < G[v].size(); i++) {

                edge &e = G[v][i];

                if (e.cap > ZERO) { que.push(e.to); }

            }

        }

        for (int i = 0; i < n; i++) {

            if (visited[i]) { continue; }

            for (int j = 0; j < G[i].size(); j++) {

                edge &e = G[i][j];

                if (e.isRev && visited[e.to]) { ret[{e.to, i}] = e.cap; }

            }

        }

        return ret;

    }

};



int N;

int a[110];

signed main() {

    cin >> N;

    reps(i, N) { cin >> a[i]; }

    int s = 0, t = N + 1;

    int X = 1e10;

    int INF = 1e14;

    Dinic<int> dnc(N + 2);

    reps(i, N) {

        dnc.addEdge(s, i, X - a[i]);

        dnc.addEdge(i, t, X);

        for (int j = i + i; j <= N; j += i) { dnc.addEdge(i, j, INF); }

    }

    cout << N * X - dnc.calcMaxFlow(s, t) << endl;

}