#include <bits/stdc++.h>
using namespace std;
const int MAX = 1123456;
int x[MAX];
int n;
int solve(int a, int b) {
  int k = 0, j = 0;
  for (int i = 1; i <= n; i++) {
    if (x[i] == 1000)
      a--;
    else
      b--;
    if (x[i] == 1000 && a >= 0 || x[i] == 2000 && b >= 0) {
      k += x[i], j += x[i] / 10;
    } else {
      k += x[i] - min(x[i], j), j -= min(x[i], j);
    }
  }
  return k;
}
int main() {
  scanf("%d", &n);
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", x + i);
    sum += x[i];
  }
  int a = 0, b = 0, ans = sum;
  for (int i = 1; i <= n; i++) {
    sum -= x[i] / 10 * 11;
    if (sum <= 0) break;
    if (x[i] == 1000)
      a++;
    else
      b++;
  }
  ans = min(ans, solve(a, b));
  ans = min(ans, solve(a + 1, b));
  ans = min(ans, solve(a, b + 1));
  ans = min(ans, solve(a - 1, b + 1));
  printf("%d\n", ans);
}
