using namespace std;

int main() {
    int N, M;

    cin >> N >> M;

    int a[N+10];
    int b[N+10];

    for (int i = 1; i <= N; ++i)
    {
      cin >> a[i];
      b[i] = 0;
    }

    b[0] = 0;
    for (int i = 1; i < N; ++i)
    {
       b[i] = (b[i-1] + a[i]) % M;
    }
    long ans = 0;

    for (int i = 0; i <= N; ++i) {
      for (int j = i+1; j <= N; ++j) {
        if(b[j] - b[i] == 0) ans++;
      }
    }

    cout << ans << endl;
}
