#include <bits/stdc++.h>
using namespace std;
int n, cnt, ary[105];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> ary[i];
    if (ary[i] == 1) ++cnt;
  }
  for (int i = 1; i < n - 1; i++)
    if (ary[i - 1] == 1 && ary[i + 1] == 1 && ary[i] == 0) ++cnt;
  cout << cnt << "\n";
  return 0;
}
