function main(input) {
  const tmp = input.trim().split('\n')
  const n = parseInt(tmp[0], 10)
  const s = tmp[1]

  let r = 0
  let g = 0
  let b = 0

  for (let i = 0; i < n; i++) {
    if (s[i] == 'R') {
      r++
    } else if (s[i] == 'G') {
      g++
    } else {
      b++
    }
  }

  let answer = r * g * b
  for (let i = 0; i < n - 1; i++) {
    for (let j = i + 1; 2 * j - i < n; j++) {
      const k = 2 * j - i
      if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) {
        answer--
      }
    }
  }

  console.log(answer)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))
