#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n;
  int a[m];
  int b = 0;
  int cnt = 0;
  cin >> m >> n >> a[m];
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) {
      if (j >= i) {
        for (int l = i; l <= j; l++) b = b + a[l];
        if (b % n == 0) cnt++;
        b = 0;
      }
    }
  cout << cnt;
  return 0;
}
