#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  long long res = 1LL << 55;
  vector<long long> psum(n + 1);
  for (int i = 0; i < n; i++) psum[i + 1] = psum[i] + a[i];
  for (int i = 0; i <= n; i++) {
    long long p0 = psum[i];
    long long p1 = max(0LL, psum[n] - psum[i] - p0 / 10);
    res = min(res, p0 + p1);
  }
  int last = -1;
  for (int i = 0; i <= n; i++) {
    long long p0 = ((last == -1) ? 0LL : psum[last]) - psum[0];
    long long p1 = max(0LL, 1000 - p0 / 10);
    long long p2 = psum[i] - psum[last + 1];
    long long p3 =
        max(0LL, psum[n] - psum[i] - (p0 / 10 - (1000 - p1) + p2 / 10));
    if (last >= 0) res = min(res, p0 + p1 + p2 + p3);
    if (i < n && a[i] == 1000) last = i;
  }
  vector<int> nex(n + 1, n);
  for (int i = n - 1; i >= 0; i--) {
    nex[i] = nex[i + 1];
    if (a[i] == 1000) nex[i] = i;
  }
  for (int i = 0; i <= n; i++) {
    if (nex[i] == n) break;
    long long p0 = psum[i];
    long long p1 = max(0LL, psum[nex[i]] - psum[i] - p0 / 10);
    long long p2 = 1000;
    long long p3 =
        max(0LL, psum[n] - psum[nex[i] + 1] -
                     (p0 / 10 - (psum[nex[i]] - psum[i] - p1) + p2 / 10));
    res = min(res, p0 + p1 + p2 + p3);
  }
  cout << res << "\n";
}
