#include <stdio.h>
int main(void)
{
	int i,j,k;
	int cnt=0, N;
	char aa[4000+2];
	scanf("%d", &N);
	for (i = 0; i < N; i++)
	{
		scanf("%s", &aa[i]);
	}
	for (i = 0; i < N; i++)
	{
		for (j = i+1; j < N; j++)
		{
			if (aa[i] == aa[j])
			{
				continue;
			}
			for (k = j+1; k < N; k++)
			{
				if (aa[i] != aa[j] && aa[i] != aa[k] && aa[j] != aa[k])
				{
					if(j-i != k-j){
						cnt++;
					}
				}
			}
		}
	}
	printf("%d\n",cnt);
	return 0;
	}