• + 5 comments
    input()
    s = input().replace(' ', '')
    print(sum(x // 2 + 1 for x in map(len, s.split('1'))) - 1)