Buggy python submission (verdict: Time Limit Exceeded):
import re
a=int(input())
b=str(input())
sum=0
c=b
d=b
i=0
for s in b:
    for n in range(i,a):
        if c[n]!=c[i]:
            j=n-i
            if a>=n:
                for m in range(n,a):
                    if c[m]!=c[i] and c[m]!=c[n]:
                        k=m-n
                        if k!=j:
                            sum+=1



    i+=1
print(sum)

Fixed submission:
a=int(input())
b=str(input())
sum=0

riron_sum=b.count('R')*b.count('G')*b.count('B')

for i in range(0,a):
    for n in range(0,a+1):
        j = i+n
        k = j+n
        #print(j)
        #print(k)
        if k>=a:
        	break

        if b[i]!=b[j] and b[j]!=b[k] and b[k]!=b[i]:
                riron_sum-=1

print(riron_sum)

Buggy python submission (verdict: Time Limit Exceeded):
import re
a=int(input())
b=str(input())
sum=0
c=b
d=b
i=0
for s in b:
    for n in range(i,a):
        if c[n]!=c[i]:
            j=n-i
            if a>=n:
                for m in range(n,a):
                    if c[m]!=c[i] and c[m]!=c[n]:
                        k=m-n
                        if k!=j:
                            sum+=1



    i+=1
print(sum)

Fixed submission:
a=int(input())
b=str(input())
sum=0

riron_sum=b.count('R')*b.count('G')*b.count('B')

for i in range(0,a):
    for n in range(0,a+1):
        j = i+n
        k = j+n
        #print(j)
        #print(k)
        if k>=a:
        	break

        if b[i]!=b[j] and b[j]!=b[k] and b[k]!=b[i]:
                riron_sum-=1

print(riron_sum)

Buggy python submission (verdict: Runtime Error):
a=int(input())
b=str(input())
sum=0

riron_sum=b.count('R')*sum=b.count('G')*sum=b.count('B')
for i in range(1,a):
    for n in range(1,i):
        if i+n>N:
            j = i+d
            k = j+d
            if b[i]!=b[j] and b[j]!=b[k] and b[k]!=b[i]:
                riron_sum-=1

print(riron_sum)

Fixed submission:
a=int(input())
b=str(input())
sum=0

riron_sum=b.count('R')*b.count('G')*b.count('B')

for i in range(0,a):
    for n in range(0,a+1):
        j = i+n
        k = j+n
        #print(j)
        #print(k)
        if k>=a:
        	break

        if b[i]!=b[j] and b[j]!=b[k] and b[k]!=b[i]:
                riron_sum-=1

print(riron_sum)

Buggy python submission (verdict: Runtime Error):
a=int(input())
b=str(input())
sum=0

riron_sum=b.count('R')*sum=b.count('G')*sum=b.count('B')
for i in range(1,a):
    for n in range(1,i):
        if i+n>N:
            j = i+d
            k = j+d
            if b[i]!=b[j] and b[j]!=b[k] and b[k]!=b[i]:
                riron_sum-=1

print(riron_sum)

Fixed submission:
a=int(input())
b=str(input())
sum=0

riron_sum=b.count('R')*b.count('G')*b.count('B')

for i in range(0,a):
    for n in range(0,a+1):
        j = i+n
        k = j+n
        #print(j)
        #print(k)
        if k>=a:
        	break

        if b[i]!=b[j] and b[j]!=b[k] and b[k]!=b[i]:
                riron_sum-=1

print(riron_sum)

Buggy python submission (verdict: Time Limit Exceeded):
import re
a=int(input())
b=str(input())
sum=0
c=b
d=b
i=0
for s in b:
    if s=="R":
        if a>=i:
            for n in range(i,a):
                if c[n]=="G":
                    j=n-i
                    if a>=n:
                        for m in range(n,a):
                            if c[m]=="B":
                                k=m-n
                                if k!=j:
                                    sum+=1
                if c[n]=="B":
                    j=n-i
                    if a>=n:
                        for m in range(n,a):
                            if c[m]=="G":
                                k=m-n
                                if k!=j:
                                    sum+=1

    if s=="G":
        if a>=i:
            for n in range(i,a):
                if c[n]=="R":
                    j=n-i
                    if a>=n:
                        for m in range(n,a):
                            if c[m]=="B":
                                k=m-n
                                if k!=j:
                                    sum+=1
                if c[n]=="B":
                    j=n-i
                    if a>=n:
                        for m in range(n,a):
                            if c[m]=="R":
                                k=m-n
                                if k!=j:
                                    sum+=1

    if s=="B":
        if a>=i:
            for n in range(i,a):
                if c[n]=="R":
                    j=n-i
                    if a>=n:
                        for m in range(n,a):
                            if c[m]=="G":
                                k=m-n
                                if k!=j:
                                    sum+=1
            for n in range(i,a):
                if c[n]=="G":
                    j=n-i
                    if a>=n:
                        for m in range(n,a):
                            if c[m]=="R":
                                k=m-n
                                if k!=j:
                                    sum+=1


    i+=1
print(sum)

Fixed submission:
a=int(input())
b=str(input())
sum=0

riron_sum=b.count('R')*b.count('G')*b.count('B')

for i in range(0,a):
    for n in range(0,a+1):
        j = i+n
        k = j+n
        #print(j)
        #print(k)
        if k>=a:
        	break

        if b[i]!=b[j] and b[j]!=b[k] and b[k]!=b[i]:
                riron_sum-=1

print(riron_sum)

Buggy python submission (verdict: Time Limit Exceeded):
import re
a=int(input())
b=str(input())
sum=0
c=b
d=b
i=0
for s in b:
    if s=="R":
        if a>=i:
            for n in range(i,a):
                if c[n]=="G":
                    j=n-i
                    if a>=n:
                        for m in range(n,a):
                            if c[m]=="B":
                                k=m-n
                                if k!=j:
                                    sum+=1
                if c[n]=="B":
                    j=n-i
                    if a>=n:
                        for m in range(n,a):
                            if c[m]=="G":
                                k=m-n
                                if k!=j:
                                    sum+=1

    if s=="G":
        if a>=i:
            for n in range(i,a):
                if c[n]=="R":
                    j=n-i
                    if a>=n:
                        for m in range(n,a):
                            if c[m]=="B":
                                k=m-n
                                if k!=j:
                                    sum+=1
                if c[n]=="B":
                    j=n-i
                    if a>=n:
                        for m in range(n,a):
                            if c[m]=="R":
                                k=m-n
                                if k!=j:
                                    sum+=1

    if s=="B":
        if a>=i:
            for n in range(i,a):
                if c[n]=="R":
                    j=n-i
                    if a>=n:
                        for m in range(n,a):
                            if c[m]=="G":
                                k=m-n
                                if k!=j:
                                    sum+=1
            for n in range(i,a):
                if c[n]=="G":
                    j=n-i
                    if a>=n:
                        for m in range(n,a):
                            if c[m]=="R":
                                k=m-n
                                if k!=j:
                                    sum+=1


    i+=1
print(sum)

Fixed submission:
a=int(input())
b=str(input())
sum=0

riron_sum=b.count('R')*b.count('G')*b.count('B')

for i in range(0,a):
    for n in range(0,a+1):
        j = i+n
        k = j+n
        #print(j)
        #print(k)
        if k>=a:
        	break

        if b[i]!=b[j] and b[j]!=b[k] and b[k]!=b[i]:
                riron_sum-=1

print(riron_sum)

Buggy python submission (verdict: Time Limit Exceeded):

a=int(input())
b=str(input())
sum=0
c=b
d=b
i=0
for s in b:
    if s=="R":
        if a>=i:
            for n in range(i,a):
                if c[n]=="G":
                    j=n-i
                    if a>=n:
                        for m in range(n,a):
                            if c[m]=="B":
                                k=m-n
                                if k!=j:
                                    sum+=1
    if s=="R":
        if a>=i:
            for n in range(i,a):
                if c[n]=="B":
                    j=n-i
                    if a>=n:
                        for m in range(n,a):
                            if c[m]=="G":
                                k=m-n
                                if k!=j:
                                    sum+=1

    if s=="G":
        if a>=i:
            for n in range(i,a):
                if c[n]=="R":
                    j=n-i
                    if a>=n:
                        for m in range(n,a):
                            if c[m]=="B":
                                k=m-n
                                if k!=j:
                                    sum+=1
    if s=="G":
        if a>=i:
            for n in range(i,a):
                if c[n]=="B":
                    j=n-i
                    if a>=n:
                        for m in range(n,a):
                            if c[m]=="R":
                                k=m-n
                                if k!=j:
                                    sum+=1

    if s=="B":
        if a>=i:
            for n in range(i,a):
                if c[n]=="R":
                    j=n-i
                    if a>=n:
                        for m in range(n,a):
                            if c[m]=="G":
                                k=m-n
                                if k!=j:
                                    sum+=1
    if s=="B":
        if a>=i:
            for n in range(i,a):
                if c[n]=="G":
                    j=n-i
                    if a>=n:
                        for m in range(n,a):
                            if c[m]=="R":
                                k=m-n
                                if k!=j:
                                    sum+=1


    i+=1
print(sum)


Fixed submission:
a=int(input())
b=str(input())
sum=0

riron_sum=b.count('R')*b.count('G')*b.count('B')

for i in range(0,a):
    for n in range(0,a+1):
        j = i+n
        k = j+n
        #print(j)
        #print(k)
        if k>=a:
        	break

        if b[i]!=b[j] and b[j]!=b[k] and b[k]!=b[i]:
                riron_sum-=1

print(riron_sum)