#include <bits/stdc++.h>
using namespace std;
int p[101];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> p[i];
  p[0] = p[n + 1] = 0;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (p[i] == 1)
      ans++;
    else {
      if (p[i - 1] == 1 && p[i + 1] == 1) ans++;
    }
  }
  cout << ans << endl;
}
