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.*;
import java.util.*;

public class D {

	static boolean test(int mask, int i) {
		return ((mask >> i) & 1) == 1;
	}

	static final int INF = Integer.MAX_VALUE / 3;
	static final int C = 11;

	int fast(int[] a) {
		int n = a.length;
		int[] pref = new int[n + 1];
		for (int i = 0; i < n; i++) {
			pref[i + 1] = pref[i] + a[i];
		}
		
		int res = INF;
		for (int i = 0; i < n; i++) {
			for (int j = i; j < i + C && j <= n; j++) {
				
				int spent = pref[i] * 10;
				int card = spent;
				
				for (int k = i; k < j; k++) {
					if (a[k] == 2) {
						spent += 20;
						card += 2;
					} else {
						int use = Math.min(card, 10);
						spent += 10 - use;
						card -= use;
					}
				}
				
				int rest = 10 * (pref[n] - pref[j]);
				int use = Math.min(card, rest);
				spent += rest - use;
				res = Math.min(res, spent);
			}
		}
		return res;
	}

	int slowPoly(int[] a) {
		int sz = a.length * 2 + 1;
		int[] dp = new int[sz];
		Arrays.fill(dp, INF);
		dp[0] = 0;

		for (int x : a) {
			int[] nxt = new int[sz];
			Arrays.fill(nxt, INF);
			for (int was = 0; was < sz; was++) {
				if (dp[was] == INF) {
					continue;
				}
				// full
				if (was + x < sz) {
					nxt[was + x] = Math.min(nxt[was + x], dp[was] + x * 10);
				}

				// ez
				int use = Math.min(was, x * 10);
				nxt[was - use] = Math.min(nxt[was - use], dp[was] + x * 10
						- use);
			}
			dp = nxt;
		}
		int ret = INF;
		for (int x : dp) {
			ret = Math.min(ret, x);
		}
		return ret;
	}

	int slow(int[] a) {
		int n = a.length;
		int res = Integer.MAX_VALUE;

		int bestMask = -1;
		
		int bestFast = Integer.MAX_VALUE;

		for (int mask = 0; mask < (1 << n); mask++) {
			int card = 0;
			int spent = 0;
			
			boolean ez1 = false;
			boolean ez2 = false;
			
			boolean goodMask = true;
			
			for (int i = 0; i < n; i++) {
				if (test(mask, i)) {
					spent += a[i] * 10;
					card += a[i];
					if ((a[i] == 1) && ez1) {
						goodMask = false;
					}
					if ((a[i] == 2) && ez2) {
						goodMask = false;
					}
				} else {
					if (a[i] == 1) {
						ez1 = true;
					} else {
						ez2 = true;
					}
					int use = Math.min(card, a[i] * 10);
					card -= use;
					spent += a[i] * 10 - use;
				}
			}
			if (spent < res) {
				bestMask = mask;
			}
			if (goodMask) {
				bestFast = Math.min(bestFast, spent);
			}
			res = Math.min(res, spent);
		}
		if (bestFast != res) {
			System.err.println(Arrays.toString(a));
			System.err.println(res);
			System.err.println(bestFast);
			System.err.println(bestMask);
			throw new AssertionError();
		}
//		System.err.println(Integer.toBinaryString(bestMask));
		return res;
	}

	void submit() {
		int n = nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt() / 1000;
		}
		out.println(slow(a) * 100);
	}

	void preCalc() {

	}

	void stress() {
		for (int n = 1;; n++) {
			System.err.println(n);
			int[] a = new int[n];
			for (int mask = 0; mask < 1 << n; mask++) {
				for (int i = 0; i < n; i++) {
					a[i] = test(mask, i) ? 1 : 2;
				}
//				if (slowPoly(a) != fast(a)) {
//					System.err.println(Arrays.toString(a));
//					System.err.println(slowPoly(a));
//					System.err.println(fast(a));
//					System.err.println(slow(a));
//					throw new AssertionError();
//				}
				slow(a);
			}
		}
	}

	void test() {

	}

	D() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		 submit();
//		stress();
		// test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new D();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

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

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}
