#include <bits/stdc++.h>
using namespace std;
inline int read(register int ans = 0, register int sgn = ' ',
                register int ch = getchar()) {
  for (; ch < '0' || ch > '9'; sgn = ch, ch = getchar())
    ;
  for (; ch >= '0' && ch <= '9'; (ans *= 10) += ch - '0', ch = getchar())
    ;
  return sgn - '-' ? ans : -ans;
}
int a[300000 + 5], f[300000 + 5][31], n;
int main() {
  n = read();
  for (register int i = 1; i <= n; a[i++] = read())
    ;
  memset(f, 0x3f, sizeof f), f[0][0] = 0;
  for (register int i = 1, j; i <= n; i++)
    for (j = 0; j <= 30; j++)
      if (f[i - 1][j] < 0x3f3f3f3f) {
        if (j + a[i] / 1000 <= 30)
          f[i][j + a[i] / 1000] =
              min(f[i][j + a[i] / 1000], f[i - 1][j] + a[i]);
        if (j >= a[i] / 100)
          f[i][j - a[i] / 100] = min(f[i][j - a[i] / 100], f[i - 1][j]);
        else
          f[i][0] = min(f[i][0], f[i - 1][j] + a[i] - j * 100);
      }
  printf("%d\n", f[n][0]);
  return 0;
}
