You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: b.go
    path of file: ./repos/codeforces-go/leetcode/biweekly/70/b
    
    the code of the file until where you have to start completion: package main

// 还原差分数组

// github.com/EndlessCheng/codeforces-go
func numberOfArrays(differences []int, lower, upper int) int {
	num, min, max := 0, 0, 0
	for _, d := range 
    
func numberOfArrays(differences []int, lower, upper int) int {
	num, min, max := 0, 0, 0
	for _, d := range differences {
		num += d // 根据差分数组还原原始数组的元素值 num
		if num < min {
			min = num
		} else if num > max {
			max = num
		}
	}
	ans := upper - lower + 1 - (max - min)
	if ans > 0 {
		return ans
	}
	return 0
}