#include using namespace std; int main() { int n; cin >> n; vector emp, fil, b(n); for (int i=0; i> b[i]; if (b[i]) fil.push_back(i); else emp.push_back(i); } int i = 0, j = 0; int ans = 0; while (i < emp.size()) { while (b[fil[j]]<=1) j++; ans += abs(emp[i]-fil[j]); i++; } cout << ans << endl; }