#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using vl = vector<ll>;
using Map = map<ll, ll>;
using T = tuple<ll, ll, ll>;
using vvl = vector<vector<ll>>;
template <typename T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
signed main(void) {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  vector<ll> P(N, 0);
  for (ll i = 0; i < N; ++i) cin >> P[i];
  ll count = 0;
  ll &ans = count;
  for (ll i = 0; i < N; ++i)
    if (P[i + 1]) ans++;
  cout << ((ans + 1) / 2) << "\n";
  return 0;
}
