#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
int a[N], n, f[N][35];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  memset(f, 0x3f, sizeof f);
  f[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 31; j++) {
      if (a[i + 1] / 1000 + j <= 31)
        f[i + 1][j + a[i + 1] / 1000] =
            min(f[i + 1][j + a[i + 1] / 1000], f[i][j] + a[i + 1]);
      if (j >= a[i + 1] / 100)
        f[i + 1][j - a[i + 1] / 100] =
            min(f[i + 1][j - a[i + 1] / 100], f[i][j]);
      else
        f[i + 1][0] = min(f[i + 1][0], f[i][j] + a[i + 1] - j * 100);
    }
  }
  int ans = 2e9;
  for (int i = 0; i <= 31; i++) ans = min(ans, f[n][i]);
  cout << ans << endl;
  return 0;
}
