#include <bits/stdc++.h>
using namespace std;
using INT = long long;
const int NN = 373737;
int a[NN];
vector<int> adj;
multiset<int> st;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  INT ans = 0, s = 0;
  for (int i = n; i; i--) {
    if (a[i] == 3) {
      ans++;
      continue;
    }
    if (a[i] == 1) {
      if (st.empty()) continue;
      int v = *st.begin();
      st.erase(st.begin());
      ans++;
      v -= 2;
      if (v == 3)
        ans++;
      else if (v)
        st.insert(v);
    } else
      st.insert(a[i]);
  }
  for (int v : st) s += v;
  ans += s / 3;
  cout << ans << endl;
  return 0;
}
