//201409-1
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;scanf("%d", &n);
int arr[n];
for (int i = 0; i < n; i++)scanf("%d", &arr[i]);sort(arr, arr + n);
int count = 0;
for (int i = 1; i < n; i++)
if (arr[i] - arr[i - 1] == 1)
count++;printf("%d", count);
return 0;}
//201409-1
#include <bits/stdc++.h>
using namespace std;
int main(){
int n, num, res = 0;scanf("%d", &n);
set<int> s;
while (n--)scanf("%d", &num), s.insert(num);
for (auto it = ++s.begin(), iter = s.begin(); it != s.end(); it++, iter++) if (*it - *iter == 1) res++;printf("%d\n", res);
return 0;}
//201409-2
#include <bits/stdc++.h>
using namespace std;
struct Node{
int rowFirst, colFirst, rowSecond, colSecond;};
int main(){
int n;scanf("%d", &n);
Node arr[n];
for (int i = 0; i < n; i++)scanf("%d%d%d%d", &arr[i].rowFirst, &arr[i].colFirst, &arr[i].rowSecond, &arr[i].colSecond);
bool flag[110][110];
for (int i = 0; i < 110; i++)
for (int j = 0; j < 110; j++)
flag[i][j] = false;
int count = 0;
for (int i = 0; i < n; i++)
for (int j = arr[i].rowFirst; j < arr[i].rowSecond; j++)
for (int k = arr[i].colFirst; k < arr[i].colSecond; k++)
if (!flag[j][k])
count++, flag[j][k] = true;printf("%d", count);
return 0;}
//201409-2
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> v(110, vector<int>(110));
int main(){
int n;scanf("%d", &n);
int res = 0;
while (n--){
int x1, y1, x2, y2;scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
for (int i = x1; i < x2; i++)
for (int j = y1; j < y2; j++)
if (v[i][j] == 0)
v[i][j] = 1, res++;}printf("%d\n", res);
return 0;}