output_description: Print the number of triplets in question.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      S
attempt: # 初期入力
  N = int(input())
  S = input()
  
  
  #
  R_index = []
  G_index = []
  B_index = []
  for i, v in enumerate(S):
      if v == "R":
          R_index.append(i)
      if v == "G":
          G_index.append(i)
      if v == "B":
          B_index.append(i)
  
  # 例　R_index各要素から等距離離れたところに左にG、右にBがあればOK
  R_B = []
  B_G = []
  count_ij_jk_onaji = 0
  for r in R_index:
      for g in G_index:
          if 0 <= g - (r - g) and g - (r - g) < N:
              # if S[g-(r-g)]=="B" and r<g:
              if S[g - (r - g)] == "B":
                  count_ij_jk_onaji += 1
              # print(r,g,g-(r-g),"B")
  for b in B_index:
      for r in R_index:
          if 0 <= r - (b - r) and r - (b - r) < N:
              # if S[r-(b-r)] == "G" and b<r:
              if S[r - (b - r)] == "G":
                  count_ij_jk_onaji += 1
                  # print(r,b,r-(b-r),"G")
  for g in G_index:
      for b in B_index:
          if 0 <= b - (g - b) and b - (g - b) < N:
              # if S[b-(g-b)] =="R" and g<b:
              if S[b - (g - b)] == "R":
                  count_ij_jk_onaji += 1
                  # print(b,g,b-(g-b),"R")
  
  
  # 3つとも異なる文字=all
  kotae_all = len(R_index) * len(G_index) * len(B_index)
  print(kotae_all - count_ij_jk_onaji)
  
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"}]