#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
long long dp[maxn][50];
int a[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  memset(dp, 63, sizeof dp);
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 50; j++) {
      if (dp[i][j] > 1e18) continue;
      if (a[i] / 1000 + j < 50)
        dp[i + 1][j + a[i] / 1000] =
            min(dp[i + 1][j + a[i] / 1000], dp[i][j] + a[i]);
      long long mini = min(j * 100, a[i]);
      dp[i + 1][j - mini / 100] =
          min(dp[i + 1][j - mini / 100], dp[i][j] + a[i] - mini);
    }
  }
  long long ans = 1e18;
  for (int i = 0; i < 50; i++) ans = min(ans, dp[n][i]);
  cout << ans << endl;
}
