int f(int n,int* A,int m){
int l = 0;
int r = 0;
int s = 0;
int ans = 0;
while(r<=n){
if (s<m){
s+=A[r];
r++;
}
else if (s>m){
s-=A[l];
l++;
}
else if (s==m){
ans++;
s+=A[r];
r++;
continue;
}
}
return ans;
}
```julia
function f58574554(A::AbstractVector{<:Integer}, m::Integer)
d = Dict(0 => 1)
c = 0
for k = cumsum(A)
c += get(d, k-m, 0)
d[k] = get(d, k, 0) + 1
end
return c
end
f58574554([1,2,3,-2,-1,5], 3) # 4
```