#include <iostream>
using namespace std;
const int N = 1E5 + 10;
typedef long long ll;
ll s[N], cnt[N];
int main(){
int n, k; cin >> n >> k;
for(int i = 1; i <= n; i ++ ) cin >> s[i];
for(int i = 1; i <= n; i ++ ) s[i] += s[i - 1];
ll res = 0;
for(int i = 1; i <= n; i ++ ){
res += cnt[s[i] % k];
cnt[s[i] % k] ++ ;
}
cout << res + cnt[0] << endl;
return 0;
}