#include <iostream>
using namespace std;
int dp[1000] = {};
int n, k;
int main() {
cin >> n;
dp[0] = 1;
dp[1] = 1;
dp[2] = 2;
for (int i = 0; i < n; i++) {
cin >> k;
for (int i = 3; i <= k; i++) {
dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
dp[k] = dp[i];
}
cout << dp[k] << endl;
}
}