func solve() { guard let n = Int(readLine() ?? "") else { return } var A: [Int] = [Int]() var B: [Int] = [Int]() var C: [Int] = [Int]() var D: [Int] = [Int]() for _ in 0..) var (pAB, pCD) = (0, 0) let (nAB, nCD) = (AB.count, CD.count) var ans = 0 while pAB < nAB && pCD < nCD { let (ab, cd) = (AB[pAB], CD[pCD]) if ab + cd > 0 { pCD += 1 } else if ab + cd < 0 { pAB += 1 } else { var countAB = 0 while pAB < nAB && ab == AB[pAB] { pAB += 1 countAB += 1 } var countCD = 0 while pCD < nCD && cd == CD[pCD] { pCD += 1 countCD += 1 } ans += countAB * countCD } } print(ans) } solve()