#include <bits/stdc++.h>
using namespace std;
const int MAX = 300100, MAXK = 105, INF = 0x3f3f3f3f;
int dp[MAX][MAXK];
int p[MAX], n;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &p[i]);
  memset(dp, INF, sizeof dp);
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    int st = p[i] / 1000;
    for (int j = 0; j < MAXK - 2; j++) {
      dp[i + 1][j + st] = min(dp[i + 1][j + st], dp[i][j] + 10 * st);
      dp[i + 1][max(0, j - 10 * st)] =
          min(dp[i + 1][max(0, j - 10 * st)], dp[i][j] + max(0, 10 * st - j));
    }
  }
  int rje = INF;
  for (int i = 0; i < MAXK; i++) rje = min(rje, dp[n][i]);
  cout << (long long)rje * 100 << endl;
  return 0;
}
