import kotlin.math.*
class Solution {
fun solution(nums: IntArray): Int{
val N = 1000+1000+1000
//에라토스테네스의 체
val isPrime = Array<Int>(N+1, {it -> 1})
for(i in 2..sqrt(N.toDouble()).toInt()){
if(isPrime[i] == 1){
for(j in i*i..N step i) isPrime[j] = 0
}
}
var answer = 0
for(i in 0..nums.size-3){
for(j in i+1..nums.size-2){
for(k in j+1..nums.size-1){
if(isPrime[nums[i]+nums[j]+nums[k]]==1) answer++
}
}
}
return answer
}
}