```
public class Solution {
public boolean check(int []array, int start, int end){
int n = array.length;
int diff = array[start+1] - array[start];
for(int i = start + 1; i < end; i++){
if(array[i] - array[i-1] != diff) return false;
}
return true;
}
public int numberOfArithmeticSlices(int[] A) {
int n = A.length, count = 0;
for(int len = 3; len <= n; len ++){
for(int i = 0; i <= n - len; i++){
int start = i, end = i+ len;
if(check(A, start, end)) count ++;
}
}
return count;
}
}
```