#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:667177216")
using namespace std;
const long long MOD = 1000000000 + 7;
long long D[3 * 100000 + 5][45];
long long rec(vector<int> &a, int pos, int have) {
  if (pos == a.size()) return 0;
  if (D[pos][have] != -1) return D[pos][have];
  long long mini = 999999999999999999;
  if (have == 0) {
    return D[pos][have] = (a[pos] + rec(a, pos + 1, have + a[pos] / 1000));
  }
  if (have >= 42) {
    return D[pos][have] = (a[pos] + rec(a, pos + 1, have - a[pos] / 100));
  }
  mini = a[pos] + rec(a, pos + 1, have + a[pos] / 1000);
  for (int i = 1; i <= min(have, a[pos] / 100); ++i) {
    mini = min(mini, a[pos] - i * 100 + rec(a, pos + 1, have - i));
  }
  return D[pos][have] = mini;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int(i) = 0; (i) < n; (i)++) scanf("%d", &a[i]);
  memset(D, -1, sizeof(D));
  cout << rec(a, 0, 0);
  return 0;
}
