You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
472 B
25 lines
472 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
int main() {
|
|
int n;
|
|
cin >> n;
|
|
vector<int> vec;
|
|
for (int i = 0; i < n; i++) {
|
|
int c;
|
|
cin >> c;
|
|
vec.push_back(c);
|
|
}
|
|
int count = 0;
|
|
for (int i = 0; i < n - 1; i++) {
|
|
for (int j = i + 1; j < n; j++) {
|
|
if (abs(vec[i] - vec[j]) == 1) {
|
|
count++;
|
|
}
|
|
}
|
|
}
|
|
cout << count << endl;
|
|
return 0;
|
|
}
|