extension Array where Element == Int { func prefixSum() -> [Int] { var sum = 0 return map { element in defer { sum += element }