22
1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000
 2
1000 2000
 19
2000 2000 1000 2000 2000 2000 2000 2000 2000 2000 2000 1000 2000 2000 2000 1000 1000 1000 2000
 20
2000 1000 2000 2000 2000 2000 2000 2000 2000 2000 1000 2000 2000 2000 1000 1000 2000 1000 1000 2000
 1
1000
 60
1000 1000 1000 2000 1000 1000 1000 2000 2000 2000 2000 1000 2000 1000 2000 1000 1000 1000 2000 2000 2000 1000 2000 1000 2000 1000 2000 2000 2000 1000 2000 2000 2000 1000 1000 2000 1000 1000 1000 2000 1000 2000 2000 2000 1000 1000 2000 1000 1000 2000 2000 1000 1000 1000 2000 2000 1000 2000 1000 2000
 57
1000 2000 2000 1000 2000 2000 1000 1000 2000 2000 1000 2000 2000 2000 2000 2000 1000 1000 2000 2000 2000 1000 1000 1000 1000 2000 2000 1000 1000 2000 1000 1000 2000 1000 1000 1000 1000 2000 2000 2000 2000 2000 2000 1000 1000 2000 2000 1000 1000 1000 1000 2000 1000 2000 2000 2000 2000
 24
2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 1000 1000
 20
2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000
 13
2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 1000 1000
 46
1000 2000 2000 2000 2000 2000 2000 1000 2000 1000 1000 1000 1000 1000 2000 2000 1000 1000 2000 2000 1000 2000 2000 1000 2000 2000 1000 2000 1000 1000 2000 1000 1000 2000 1000 2000 1000 1000 1000 2000 2000 1000 1000 1000 2000 1000
 20
2000 2000 2000 2000 2000 2000 2000 2000 2000 1000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000
 11
2000 2000 2000 1000 1000 1000 1000 2000 2000 2000 2000
 6
1000 2000 2000 2000 1000 2000
 2
1000 1000
 12
2000 2000 2000 2000 2000 2000 1000 2000 2000 2000 2000 1000
 8
2000 1000 2000 1000 2000 2000 2000 1000
 12
2000 2000 2000 2000 2000 1000 2000 2000 2000 2000 2000 1000
 34
2000 1000 2000 2000 1000 1000 1000 2000 2000 1000 2000 2000 1000 1000 2000 2000 1000 1000 2000 2000 1000 1000 1000 2000 1000 1000 2000 2000 2000 2000 1000 1000 2000 2000
 10
2000 1000 2000 2000 2000 2000 2000 2000 1000 2000
 4
1000 1000 1000 1000
 12
2000 2000 2000 2000 2000 2000 2000 2000 2000 1000 2000 1000
 1
2000
 12
1000 1000 2000 1000 2000 1000 1000 1000 1000 1000 2000 1000
 8
2000 2000 1000 1000 1000 2000 1000 1000
 15
2000 2000 1000 2000 2000 1000 1000 2000 2000 1000 2000 2000 2000 2000 2000
 17
2000 2000 2000 2000 2000 1000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000
 16
2000 1000 2000 2000 1000 1000 2000 1000 2000 2000 1000 1000 1000 1000 2000 1000
 20
1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000
 20
1000 1000 1000 2000 2000 2000 2000 2000 1000 1000 1000 2000 2000 2000 2000 2000 1000 1000 1000 2000
 8
2000 2000 2000 2000 2000 1000 2000 1000
 17
1000 1000 2000 1000 1000 1000 2000 2000 1000 1000 2000 1000 2000 2000 2000 1000 1000
 8
1000 1000 2000 2000 2000 2000 2000 1000
 7
2000 2000 2000 2000 1000 1000 1000
 18
2000 1000 1000 2000 1000 2000 1000 2000 1000 1000 1000 2000 1000 1000 1000 1000 2000 2000
 8
2000 1000 1000 1000 2000 1000 1000 2000
 37
1000 2000 2000 1000 2000 2000 1000 1000 2000 1000 1000 2000 1000 2000 1000 1000 2000 2000 1000 2000 1000 1000 2000 1000 2000 2000 1000 1000 1000 2000 2000 2000 2000 2000 1000 2000 1000
 16
1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 2000 1000
 17
2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 1000 2000
 70
1000 2000 2000 2000 1000 1000 2000 2000 2000 2000 2000 2000 2000 1000 1000 2000 2000 2000 2000 2000 1000 1000 1000 1000 1000 2000 2000 2000 2000 2000 2000 2000 2000 1000 2000 1000 1000 2000 1000 2000 1000 1000 2000 1000 1000 1000 2000 2000 1000 2000 2000 2000 1000 2000 1000 2000 2000 2000 2000 2000 2000 2000 2000 1000 2000 2000 2000 1000 2000 2000
 31
1000 2000 1000 2000 2000 2000 2000 2000 1000 1000 2000 1000 1000 1000 2000 2000 1000 1000 2000 1000 1000 1000 1000 2000 1000 2000 2000 1000 1000 1000 2000
 19
2000 2000 1000 2000 2000 2000 2000 2000 2000 2000 2000 1000 2000 2000 2000 1000 1000 2000 1000

30000 2900 30000 31000 1000 81900 80000 41900 36400 21900 61900 35500 16400 9200 1900 20000 11900 20000 47300 16400 3700 20000 2000 13700 10000 23700 30000 21000 18200 28200 12800 21900 11900 10000 22800 10100 51000 15500 30000 105500 41000 30000
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
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;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            int l = 0;
            int r = n;
            while (r - l > 5) {
                int m1 = (2 * l + r) / 3;
                int m2 = (l + 2 * r) / 3;
                if (eval(a, m1) > eval(a, m2)) {
                    l = m1;
                } else {
                    r = m2;
                }
            }
            int ans = Integer.MAX_VALUE;
            for (int i = l; i <= r; i++) {
                ans = Math.min(ans, eval(a, i));
            }
            out.println(ans);
        }

        private int eval(int[] a, int m) {
            int cur = 0;
            int bonus = 0;
            for (int i = 0; i < m && i < a.length; i++) {
                cur += a[i];
                bonus += a[i] / 10;
            }
            for (int i = m; i < a.length; i++) {
                if (i < 0) {
                    i = 0;
                    continue;
                }
                int need = a[i];
                int fromBonus = Math.min(bonus, need);
                cur += need - fromBonus;
                bonus -= fromBonus;
            }
            return cur;
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

