N=gets.to_i
A=gets.split.map(&:to_i)
ans=0

for i in 0..60
  cnt=0
  for j in 0..N-1
    cnt+=A[j][i]
  end
  if(cnt==0)
    L=i
  end
end

for i in 0..L-1
  p=0
  for j in 0..N-1
    p+=A[j][i]
  end
  ans+=p*(N-p)
end

puts ans