#include #include int main() { int N, Q; std::cin >> N >> Q; std::vector A(N); for (int i = 0; i < N; ++i) { std::cin >> A[i]; } for (int i = 0; i < Q; ++i) { int L, R, X; std::cin >> L >> R >> X; int cnt = 0; for (int j = L - 1; j < R; ++j) { if (A[j] % X == 0) { cnt++; } } std::cout << cnt << std::endl; } return 0; }