int solution(vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
int res = 0;
int total1 = 0;
int isFirstLoop = true;
int temp = 0;
for(int i = 0; i < A.size();i++)
{
if(A[i] == 0 )
{
if(isFirstLoop)
{
isFirstLoop = false;
for(int j = i; j < A.size(); j ++)
{
if(A[j] == 1)
{
total1++;
res++;
}
}
}
else
{
res+= (total1-temp);
}
//temp = 0;
}
else if(A[i] == 1)
{
temp++;
}
}
return res;
}