Yasin has an array a containing n integers. Yasin is a 5 year old, so he loves ultimate weird things.

Yasin denotes weirdness of an array as maximum gcd(ai, aj) value among all 1 ≤ i < j ≤ n. For n ≤ 1 weirdness is equal to 0, gcd(x, y) is the greatest common divisor of integers x and y.

He also defines the ultimate weirdness of an array. Ultimate weirdness is <image> where f(i, j) is weirdness of the new array a obtained by removing all elements between i and j inclusive, so new array is [a1... ai - 1, aj + 1... an].

Since 5 year old boys can't code, Yasin asks for your help to find the value of ultimate weirdness of the given array a!

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of elements in a.

The next line contains n integers ai (1 ≤ ai ≤ 200 000), where the i-th number is equal to the i-th element of the array a. It is guaranteed that all ai are distinct.

Output

Print a single line containing the value of ultimate weirdness of the array a. 

Example

Input

3
2 6 3


Output

6

Note

Consider the first sample.

  * f(1, 1) is equal to 3. 
  * f(2, 2) is equal to 1. 
  * f(3, 3) is equal to 2. 
  * f(1, 2), f(1, 3) and f(2, 3) are equal to 0. 

Thus the answer is 3 + 0 + 0 + 1 + 0 + 2 = 6.
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Map;
import java.io.OutputStreamWriter;
import java.util.NoSuchElementException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import java.io.BufferedWriter;
import java.io.IOException;
import java.util.TreeMap;
import java.util.Map.Entry;
import java.io.Writer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, OutputWriter out) {

            final int MAX = (int) (2e5 + 5);
            int n;
            IntArrayList[] positions;

            n = in.readInt();

            positions = new IntArrayList[MAX];
            for (int i = 0; i < positions.length; i++) {
                positions[i] = new IntArrayList();
            }

            for (int i = 0; i < n; i++) {
                positions[in.readInt()].add(i);
            }

            long[] countPairs = new long[MAX];
            Foo foo = new Foo(n);
            countPairs[MAX - 1] = (long) n * n - foo.getSum();
            for (int LCM = MAX - 2; LCM >= 1; LCM--) {
                int b1 = n, b2 = n;
                int bk1 = -1, bk = -1;
                for (int xx = LCM; xx < MAX; xx += LCM) {
                    for (int i = 0; i < Math.min(2, positions[xx].size()); i++) {
                        int pos = positions[xx].get(i);
                        if (b1 >= pos) {
                            b2 = b1;
                            b1 = pos;
                        } else if (b2 >= pos) {
                            b2 = pos;
                        }
                        if (bk <= pos) {
                            bk1 = bk;
                            bk = pos;
                        } else if (bk1 <= pos) {
                            bk1 = pos;
                        }
                    }
                }

                if (b1 != n && b2 != n) {
//                out.printLine(foo.map);
                    foo.upd(b2 + 1, n);
                    foo.upd(b1 + 1, bk);
                    foo.upd(0, bk1);
                    countPairs[LCM] = (long) n * n - foo.getSum();
//                out.printLine("countPairs[" + LCM + "] = " + countPairs[LCM], ",", foo.getSum(), ", " + foo.map);
                } else {
                    countPairs[LCM] = countPairs[LCM + 1];
                }
            }

//        for (int i = 0; i < countPairs.length; i++) {
//            out.printLine(i, countPairs[i]);
//        }

            long ans = 0;
            for (int LCM = 1; LCM + 1 < countPairs.length; LCM++) {
                ans += (long) LCM * (countPairs[LCM + 1] - countPairs[LCM]);
            }
            out.printLine(ans);

            //  a[4]    a[30]   a[35]  a[30]
            //  0..34    -> 34
            // 34..N-1   -> n
            //  sum( right[i] - i )

//        Random rnd = new Random(1);
//        for (int i = 0; i < 1; i++) {
//            final int n = (int) 1e5;
//            final Foo a = new Foo(n);
//            final FooBF b = new FooBF(n);
//            if (a.sum != b.getSum()) {
//                throw new RuntimeException("Fuck ");
//            }
//            for (int j = 0; j < 100; j++) {
//                final int pos = rnd.nextInt(n);
//                final int val = rnd.nextInt((int) 1e5);
//                a.upd(pos, val);
//                b.upd(pos, val);
//                System.err.println(a.sum + "\n" + Integer.MAX_VALUE);
//                if (a.sum != b.getSum()) {
//                    throw new RuntimeException("Fuck " + i + " " + j + "      " + a.sum + " " + b.getSum() + "     "
//                            + pos + " " + val + "\n" + Arrays.toString(b.a) + "\n" + a.map);
//                }
//            }
//        }


        }

        class Foo {
            int n;
            TreeMap<Integer, Integer> map;
            long sum;

            public Foo(int n) {
                this.n = n;
                map = new TreeMap<>();
                for (int i = 0; i < n; i++) {
                    map.put(i, i);
                    sum += i;
                }
            }

            public void upd(int position, int value) {
//            System.err.println(position + " " + value + "    " + map);
                if (map.floorEntry(position).getValue() < value) {
                    Map.Entry<Integer, Integer> cur = map.lowerEntry(position);
                    if (cur != null) {
                        Map.Entry<Integer, Integer> next = map.higherEntry(cur.getKey());
                        if (next == null) {
                            sum -= (long) (n - position) * cur.getValue();
                        } else {
                            sum -= (long) (next.getKey() - position) * cur.getValue();
                        }
                    }

                    while (true) {
                        cur = map.ceilingEntry(position);
                        if (cur != null && cur.getValue() <= value) {
                            map.remove(cur.getKey());
                            Map.Entry<Integer, Integer> next = map.higherEntry(position);
                            if (next == null) {
                                sum -= (long) (n - cur.getKey()) * cur.getValue();
                            } else {
                                sum -= (long) (next.getKey() - cur.getKey()) * cur.getValue();
                            }
                        } else {
                            break;
                        }
                    }

                    Map.Entry<Integer, Integer> next = map.higherEntry(position);
                    if (next == null) {
                        sum += (long) (n - position) * value;
                    } else {
                        sum += (long) (next.getKey() - position) * value;
                    }
                    map.put(position, value);
                }
//            System.err.println(position + " " + value + "  " + sum + "    " + map);
            }

            public long getSum() {
                return sum;
            }

        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static interface IntList extends IntReversableCollection {
        public abstract int get(int index);

        public abstract void addAt(int index, int value);

        public abstract void removeAt(int index);

        default public IntIterator intIterator() {
            return new IntIterator() {
                private int at;
                private boolean removed;

                public int value() {
                    if (removed) {
                        throw new IllegalStateException();
                    }
                    return get(at);
                }

                public boolean advance() {
                    at++;
                    removed = false;
                    return isValid();
                }

                public boolean isValid() {
                    return !removed && at < size();
                }

                public void remove() {
                    removeAt(at);
                    at--;
                    removed = true;
                }
            };
        }


        default public void add(int value) {
            addAt(size(), value);
        }

    }

    static interface IntReversableCollection extends IntCollection {
    }

    static abstract class IntAbstractStream implements IntStream {

        public String toString() {
            StringBuilder builder = new StringBuilder();
            boolean first = true;
            for (IntIterator it = intIterator(); it.isValid(); it.advance()) {
                if (first) {
                    first = false;
                } else {
                    builder.append(' ');
                }
                builder.append(it.value());
            }
            return builder.toString();
        }


        public boolean equals(Object o) {
            if (!(o instanceof IntStream)) {
                return false;
            }
            IntStream c = (IntStream) o;
            IntIterator it = intIterator();
            IntIterator jt = c.intIterator();
            while (it.isValid() && jt.isValid()) {
                if (it.value() != jt.value()) {
                    return false;
                }
                it.advance();
                jt.advance();
            }
            return !it.isValid() && !jt.isValid();
        }


        public int hashCode() {
            int result = 0;
            for (IntIterator it = intIterator(); it.isValid(); it.advance()) {
                result *= 31;
                result += it.value();
            }
            return result;
        }

    }

    static interface IntCollection extends IntStream {
        public int size();

        default public void add(int value) {
            throw new UnsupportedOperationException();
        }

        default public IntCollection addAll(IntStream values) {
            for (IntIterator it = values.intIterator(); it.isValid(); it.advance()) {
                add(it.value());
            }
            return this;
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void printLine(long i) {
            writer.println(i);
        }

    }

    static interface IntIterator {
        public int value() throws NoSuchElementException;

        public boolean advance();

        public boolean isValid();

    }

    static class IntArrayList extends IntAbstractStream implements IntList {
        private int size;
        private int[] data;

        public IntArrayList() {
            this(3);
        }

        public IntArrayList(int capacity) {
            data = new int[capacity];
        }

        public IntArrayList(IntCollection c) {
            this(c.size());
            addAll(c);
        }

        public IntArrayList(IntStream c) {
            this();
            if (c instanceof IntCollection) {
                ensureCapacity(((IntCollection) c).size());
            }
            addAll(c);
        }

        public IntArrayList(IntArrayList c) {
            size = c.size();
            data = c.data.clone();
        }

        public IntArrayList(int[] arr) {
            size = arr.length;
            data = arr.clone();
        }

        public int size() {
            return size;
        }

        public int get(int at) {
            if (at >= size) {
                throw new IndexOutOfBoundsException("at = " + at + ", size = " + size);
            }
            return data[at];
        }

        private void ensureCapacity(int capacity) {
            if (data.length >= capacity) {
                return;
            }
            capacity = Math.max(2 * data.length, capacity);
            data = Arrays.copyOf(data, capacity);
        }

        public void addAt(int index, int value) {
            ensureCapacity(size + 1);
            if (index > size || index < 0) {
                throw new IndexOutOfBoundsException("at = " + index + ", size = " + size);
            }
            if (index != size) {
                System.arraycopy(data, index, data, index + 1, size - index);
            }
            data[index] = value;
            size++;
        }

        public void removeAt(int index) {
            if (index >= size || index < 0) {
                throw new IndexOutOfBoundsException("at = " + index + ", size = " + size);
            }
            if (index != size - 1) {
                System.arraycopy(data, index + 1, data, index, size - index - 1);
            }
            size--;
        }

    }

    static interface IntStream extends Iterable<Integer>, Comparable<IntStream> {
        public IntIterator intIterator();

        default public Iterator<Integer> iterator() {
            return new Iterator<Integer>() {
                private IntIterator it = intIterator();

                public boolean hasNext() {
                    return it.isValid();
                }

                public Integer next() {
                    int result = it.value();
                    it.advance();
                    return result;
                }
            };
        }

        default public int compareTo(IntStream c) {
            IntIterator it = intIterator();
            IntIterator jt = c.intIterator();
            while (it.isValid() && jt.isValid()) {
                int i = it.value();
                int j = jt.value();
                if (i < j) {
                    return -1;
                } else if (i > j) {
                    return 1;
                }
                it.advance();
                jt.advance();
            }
            if (it.isValid()) {
                return 1;
            }
            if (jt.isValid()) {
                return -1;
            }
            return 0;
        }

    }
}

