output_description: Print the number of triplets in question.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      S
attempt: def SearchCombination_RGB(Str):
      Sum_Comb = 0
      Num_R = 0
      Num_G = 0
      Num_B = 0
      for i in range(len(Str)):
          if Str[i] == "R":
              Num_R += 1
          elif Str[i] == "G":
              Num_G += 1
          else:
              Num_B += 1
      Num_Comb = Num_R * Num_G * Num_B
  
      if Num_Comb == 0:
          return 0
      for Pos1 in range(0, len(Str) - 2):
          for Pos2 in range(Pos1 + 1, len(Str) - 1):
              if Str[Pos1] != Str[Pos2]:
                  Pos3 = 2 * Pos2 - Pos1
                  if (
                      Pos3 < len(Str)
                      and Str[Pos3] != Str[Pos1]
                      and Str[Pos3] != Str[Pos2]
                  ):
                      Sum_Comb += 1
  
      return Num_Comb - Sum_Comb
  
  
  Str = [input() for i in range(2)]
  # print(Str, ", len = ", len(Str))
  
  
  print(SearchCombination_RGB(Str[1].strip()))
  
problem_description: Statement
  
  We have a string S of length N consisting of `R`, `G`, and `B`.
  
  Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy
  both of the following conditions:
  
    * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k.
    * j - i \neq k - j.
samples: [{"input": "4\n    RRGB", "output": "1\n    \n\nOnly the triplet (1,~3,~4) satisfies both conditions. The triplet (2,~3,~4)\nsatisfies the first condition but not the second, so it does not count.\n\n* * *"}, {"input": "39\n    RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB", "output": "1800"}]