#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAXN = 312345;
const int INF = 0x3f3f3f3f;
int n;
int a[MAXN];
int psum[MAXN];
int rsum(int p, int q) {
  if (q < p) return 0;
  return psum[q + 1] - psum[p];
}
int sub(int p1, int b1, int p2, int b2) {
  int cost = p1;
  int bonus = p1 / 10;
  int y = min(bonus, b1);
  bonus -= y;
  cost += b1 - y;
  cost += p2;
  bonus += p2 / 10;
  y = min(bonus, b2);
  cost += b2 - y;
  return cost;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    psum[i + 1] = psum[i] + a[i];
  }
  int sol = INF;
  int last = -1;
  int next = -1;
  for (int i = 0; i < n; i++) {
    if (a[i] == 1000) {
      last = i;
    }
    next = max(next, i);
    while (next < n and a[next] != 1000) next++;
    sol = min(sol, sub(rsum(0, i), rsum(i + 1, n - 1), 0, 0));
    if (last != -1) {
      sol = min(sol, sub(rsum(0, last - 1), a[last], rsum(last + 1, i),
                         rsum(i + 1, n - 1)));
    }
    if (next < n) {
      sol = min(sol, sub(rsum(0, i), rsum(i + 1, next - 1), a[next],
                         rsum(next + 1, n - 1)));
    }
  }
  cout << sol << endl;
}
