output_description: Print the number of triplets in question.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      S
attempt: # -*- coding: utf-8 -*-
  """
  Created on Sun Apr 12 20:59:07 2020
  
  @author: naoki
  """
  
  N = int(input())
  S = str(input())
  
  Dp = [[0 for _ in range(3)] for _ in range(N)]
  
  if S[0] == "R":
      Dp[0][0] = 1
  elif S[0] == "G":
      Dp[0][1] = 1
  elif S[0] == "B":
      Dp[0][2] = 1
  
  allcount = 0
  for j in range(1, N):
      Dp[j][0] = Dp[j - 1][0]
      Dp[j][1] = Dp[j - 1][1]
      Dp[j][2] = Dp[j - 1][2]
  
      if S[j] == "R":
          Dp[j][0] += 1
          allcount += Dp[j - 1][1] * Dp[j - 1][2]
      elif S[j] == "G":
          Dp[j][1] += 1
          allcount += Dp[j - 1][0] * Dp[j - 1][2]
      elif S[j] == "B":
          Dp[j][2] += 1
          allcount += Dp[j - 1][0] * Dp[j - 1][1]
  
  for j in range(1, N):
      for i in range(1, j):
          if j - i - i >= 0:
              if S[j - i] != S[j - 2 * i] and S[j - i] != S[j] and S[j - 2 * i] != S[j]:
                  allcount -= 1
                  pass
  print(allcount)
  
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"}]