#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[105], i, n, s = 0;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  if (a[1] == 1) s++;
  for (i = 2; i < n; i++)
    if (a[i] == 1)
      s++;
    else {
      if (a[i - 1] == 1 && a[i + 1] == 1) s++;
    }
  if (n != 1)
    if (a[n] == 1) s++;
  cout << s << endl;
  return 0;
}
