#include <bits/stdc++.h>
using namespace std;
const long long linf = 1e18 + 5;
int mod = (int)1e9 + 7;
const int logN = 18;
const int inf = 1e9 + 9;
const int N = 4e5 + 6;
int dp[N][105], a[N], n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int x = n; x >= 1; x--) {
    for (int got = 50; got >= 0; got--) {
      dp[x][got] = dp[x + 1][got + a[x] / 1000] + a[x];
      if (got >= a[x] / 100)
        dp[x][got] = min(dp[x][got], dp[x + 1][got - a[x] / 100]);
      else
        dp[x][got] = min(dp[x][got], dp[x + 1][0] + a[x] - got * 100);
    }
    for (int got = 51; got <= 100; got++) dp[x][got] = inf;
  }
  cout << dp[1][0] << '\n';
  return 0;
}
