#include <bits/stdc++.h>
#define int long long

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define FI first
#define SE second
#define PB(a) push_back(a)
#define DEBUG(x) cerr << __LINE__ << ":" << #x << ": " << x << "\n";
#define SZ(x) ((int)(x).size())
#define SO(x) sizeof((x)) / sizeof((x)[0])
using namespace std;
using lint = long long;
struct Fast{Fast(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};} fast;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
inline int in() {int x; cin >> x; return x;}
inline lint IN() {lint x; cin >> x; return x;}
inline void co(int a[], int n) {REP(i, n) cout << a[i] << " "; cout << "\n";}
//if (IO > 1e5){lint a;	scanf(%lld, &a);	printf("%lld\n", a);}

signed main(){
	
	int n = in(); int m = in();	int a[n];
	REP(i,n) a[i] = in();
	int b[n][n] = {};	int ans = 0;
	REP(i,n){
		FOR(j,i,n){
			FOR(k,i,j+1){
				if (a[k] % m ==0 and a[k] >= m){
					a[k] = a[k]%m;
				}
				b[i][j] += a[k];
				//DEBUG(k);
			}
			if (b[i][j] % m == 0){
				++ans;
				//cout << i << j << "\n";
			}
			//cout << i << " " << j << ":" << b[i][j] << "\n";
		}
	}
	cout << ans << "\n";
	//cout << "Hello World" << "\n";
	return 0;
}
