#include <bits/stdc++.h>
using namespace std;

int n, k;

double kitaichi(vector<int> p, int start, int k){
  double ans;
  for (int i = 0; i < k; i++){
    double sum = 0;
    for (int j = 1; j <= p[start+i]; j++){
      sum += j;
    }
    ans += sum/p[start+i];
  } 
  return ans;
}
 
int main() {
  cin >> n >> k;
  vector<int> p(n);
  for (int i = 0; i < n; i++){
    cin >> p.at(i);
  }
  int sum = 0;
  int start;
  int s = 0;
  for (int i = 0; i  < 1; i++){
    for (int j = 0; j < k; j++){ 
      s += p.at(i+j);
    }
    sum = s;
    start = i;
  }
  for (int i = 1; i + k <= n; i++){
    s += p.at(i+k-1);
    s -= p.at(i-1);
    if (sum < s){
      sum = s;
      start = i;
    }
  }
  cout << fixed << setprecision(15) << kitaichi(p, start, k) << endl;
}
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////


void solve(){
    ll n,m;
    cin >> n >> m;
    Vi mods(n),sum(n+1);
    rp(i,n){
        cin >> mods.at(i);
        mods.at(i)%=m;
    }
    sum[0]=0;
    rp(i,n){
        sum[i+1]=sum[i]+mods[i];
        sum[i+1]%=m;
    }
    sort(all(sum));
    ll ans=0;
    ll ctr=1;
    rp(i,n){
        if(sum[i]==sum[i+1]){
            ctr++;
        }
        else{
            ans += ctr*(ctr-1)/2;
            ctr=1;
        }
    }
    ans+=ctr*(ctr-1)/2;
    print(ans);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}