#include <bits/stdc++.h>
using namespace std;
long long n, d, tab[10010], inf = 1e18, ans;
set<long long> v;
long long mini(long long x) {
  long long ret = inf;
  for (int a = 1; a <= n; a++) {
    ret = min(ret, abs(tab[a] - x));
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> d;
  for (int a = 1; a <= n; a++) {
    cin >> tab[a];
  }
  sort(tab + 1, tab + n + 1);
  tab[0] = -inf;
  tab[n + 1] = inf;
  for (int a = 1; a <= n; a++) {
    v.insert(tab[a] - d);
    v.insert(tab[a] + d);
  }
  for (int x : v) {
    if (mini(x) == d) ans++;
  }
  cout << ans << endl;
  return 0;
}
