Count Of Subarrays With Equal Number Of 0s 1s And 2s

easy
1. You are given an array that contains only 0s, 1s, and 2s.
2. You have to find the count of subarrays with equal number of 0s, 1s, and 2s.

Input Format

A number N arr1 arr2.. N numbers

Output Format

A number representing count of subarrays with an equal number of 0s, 1s, and 2s.

Constraints

A number representing the count of subarrays with equal number of 0s, 1s, and 2s.

Example

Input
7
0 1 0 2 0 1 0
Output
2
Previous
Longest Subarray With Equal Number Of 0s 1s And 2s
Next
Pairs With Equal Sum

Related Questions