#include <bits/stdc++.h>
using namespace std;
long long dp[300005][35], n;
int ara[600005];
long long dp_func(int pos, int ase) {
  if (pos > n) return 0;
  if (dp[pos][ase] != -1) return dp[pos][ase];
  long long ret = 21474836499999;
  ret = min(ret, dp_func(pos + 1, max(ase - ara[pos] / 100, 0)) +
                     max((ara[pos] - (ase * 100)), 0));
  if (ase < 29) {
    ret = min(ret, dp_func(pos + 1, ase + (ara[pos] / 1000)) + ara[pos]);
  }
  return dp[pos][ase] = ret;
}
int main() {
  int i, j, k, l, m;
  memset(dp, -1, sizeof dp);
  scanf("%d", &m);
  for (i = 1; i <= m; i++) {
    scanf("%d", &l);
    if (l == 1000)
      ara[++n] = l;
    else {
      ara[++n] = 2000;
    }
  }
  long long ret = dp_func(1, 0);
  cout << ret << endl;
}
