```
class Solution {
func numberOfArithmeticSlices(_ A: [Int]) -> Int {
var count = 1
var res = 0
if A.count <= 2
{
return 0
}
else {
for n in 1..<A.count-1
{
if ((A[n] - A[n-1]) == (A[n+1] - A[n]))
{
res += count
count += 1
}
else
{
count = 1
}
}
return res
}
}
}
```