#include <bits/stdc++.h>
using namespace std;
long long dx[4] = {-1, 0, 1, 0};
long long dy[4] = {0, 1, 0, -1};
int main() {
  long long a[100005], t, i = 0, j, k, p, q, n, m, count = 0, flag = 0, ans = 0,
                          sum = 0, max1, min1, pos, tmp;
  t = 1;
  while (t--) {
    scanf("%lld%lld", &n, &m);
    for (i = 0; i < n; i++) scanf("%lld", &a[i]);
    map<long long, long long> M;
    ans = 0;
    for (i = 0; i < n; i++) {
      p = a[i] - m;
      q = 2000000009;
      for (j = 0; j < n; j++) q = min(q, abs(p - a[j]));
      if (M[p] == 0 && q == m) {
        ans++;
        M[p] = 1;
      }
      p = a[i] + m;
      q = 2000000009;
      for (j = 0; j < n; j++) q = min(q, abs(p - a[j]));
      if (M[p] == 0 && q == m) {
        ans++;
        M[p] = 1;
      }
    }
    printf("%lld\n", ans);
  }
  return 0;
}
