#include <iostream>
#include <vector>
#include <cassert>

int main() {
	int N, c = 0, D = 0, E = 0, V, X, F = 0;
	std::vector<int> A[N];
	std::cin >> N;
	for (int i = 0; i < N; i++) {
		std::cin >> A[i];
	}
		for (int j = 0; j < N; j++) {
			V = j;
			while (V < N) {
				D = A[j];
				if (D == 0) {
					c++;
					D = 0;
				}
				V++;
			}
		}

		for (int h = 0; h < N; h++) {
			X = h;
			while (X < N) {
				D = A[N - h];
				if (F == 0) {
					c++;
					F = 0;
				}
				X++;
			}
		}
	
	
	std::cout << c <<endl;
	
	
	
	
	return 0;
}