#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5;
long long n, a[N], dp[N][40];
void solveTestCase() {
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j < 40; j++) dp[i][j] = 1e18;
  }
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  if (a[0] == 1000)
    dp[0][1] = 1000;
  else
    dp[0][2] = 2000;
  for (long long i = 1; i < n; i++) {
    if (a[i] == 1000) {
      for (long long j = 1; j < 40; j++) dp[i][j] = dp[i - 1][j - 1] + 1000;
      for (long long j = 0; j < 30; j++)
        dp[i][j] = min(dp[i][j], dp[i - 1][j + 10]);
      for (long long j = 1; j <= 10; j++)
        dp[i][0] = min(dp[i][0], dp[i - 1][j] + 1000 - j * 100);
    } else {
      for (long long j = 2; j < 40; j++) dp[i][j] = dp[i - 1][j - 2] + 2000;
      for (long long j = 0; j < 20; j++)
        dp[i][j] = min(dp[i][j], dp[i - 1][j + 20]);
      for (long long j = 1; j <= 20; j++)
        dp[i][0] = min(dp[i][0], dp[i - 1][j] + 2000 - j * 100);
    }
  }
  cout << min({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]});
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long t = 1;
  while (t--) solveTestCase();
}
