#include using namespace std; int main() { int n; cin >> n; vector zeros; for (int i = 0; i < n; i++) { int a; cin >> a; if (a == 0) zeros.push_back(i); } int ans = 0; for (int i = 0; i < n; i++) { auto it = lower_bound(zeros.begin(), zeros.end(), i); if (it != zeros.end()) { ans += n - (*it); } } cout << ans << '\n'; return 0; }