{"raw_statement":[{"iden":"problem statement","content":"We have a string $S$ of length $N$ consisting of `R`, `G`, and `B`.\nFind the number of triples $(i,~j,~k)~(1 \\leq i < j < k \\leq N)$ that satisfy both of the following conditions:\n\n*   $S_i \\neq S_j$, $S_i \\neq S_k$, and $S_j \\neq S_k$.\n*   $j - i \\neq k - j$."},{"iden":"constraints","content":"*   $1 \\leq N \\leq 4000$\n*   $S$ is a string of length $N$ consisting of `R`, `G`, and `B`."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$\n$S$"},{"iden":"sample input 1","content":"4\nRRGB"},{"iden":"sample output 1","content":"1\n\nOnly the triplet $(1,~3,~4)$ satisfies both conditions. The triplet $(2,~3,~4)$ satisfies the first condition but not the second, so it does not count."},{"iden":"sample input 2","content":"39\nRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB"},{"iden":"sample output 2","content":"1800"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}