import Foundation

func gcd(_ a_: Int, _ b_: Int) -> Int {
    var a = a_
    var b = b_
    while a % b != 0 {
        (a, b) = (b, a%b)
    }
    return b
}

func readInt() -> [Int]{
    return readLine()!.split(separator: " ").map{Int($0)!}
}

func main() {
    let N = Int(readLine()!)!
    let S = ["❤️"] + Array(readLine()!)
    var r = 0
    var g = 0
    var b = 0
    
    for c in S {
        if c == "R" { r += 1 }
        if c == "G" { g += 1 }
        if c == "B" { b += 1 }
    }
        
    var ans = r * g * b
    print(ans)

    for i in 1...(N-2) {
        for j in (i+1)...(N-1) {
            let x = j - i
            let k = j + x
            if k <= N && S[i] != S[j] && S[i] != S[k] && S[j] != S[k] {
                ans -= 1
            }
        }
    }
    
    print(ans)
}

main()
