let n = Int(readLine()!)!
var arr = [Int]()
for _ in 0..<n {
let num = Int(readLine()!)!
var dp = [0,1,2,4]
if num >= 4 {
for i in 4...num {
dp.append(dp[i-1] + dp[i-2] + dp[i-3])
}
}
arr.append(dp[num])
}
for i in arr {
print(i)
}