#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const double inf = 1e15;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, x[300500], all, a, b;
int solve(int a, int b) {
  int ans = 0, j = 0;
  for (int i = 1; i <= n; i++) {
    if ((a > 0 && x[i] == 1000) || (b > 0 && x[i] == 2000))
      j += x[i] / 10, ans += x[i];
    else
      ans += x[i] - min(x[i], j), j -= min(x[i], j);
    if (x[i] == 1000)
      a--;
    else
      b--;
  }
  return ans;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    x[i] = read();
    all += x[i];
  }
  for (int i = 1; i <= n; i++) {
    all -= x[i] / 10 * 11;
    if (all < 0) break;
    if (x[i] == 1000)
      a++;
    else
      b++;
  }
  int ans = min(solve(a, b), min(solve(a + 1, b), solve(a - 1, b + 1)));
  printf("%d\n", ans);
  return 0;
}
