#include<stdio.h>

int main(void){
  int N = 0;
  char a[4010];
  int i=0,j=1,k=2;
  int count = 0;
  scanf("%d\n",&N);
  for(int i =0;i < N;i++){
    scanf("%s",&a[i]);
  }

  for(i = 0; i < j; i++){
    for(j = (i+1); j < k; j++){
      for(k = (j+1);k<N;k++){
        if((a[i] != a[j])&&(a[j] != a[k])){
          if(a[k] != a[i]){
            if((j - i) != (k - j)){
              count++;
            }
          }
        }
      }
    }
  }
  printf("%d\n",count );
  return 0;
}
