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