#include <bits/stdc++.h>
using namespace std;
long long n, x;
long long l, r, sum;
long long ans[1000000 + 5];
long long a[1000000 + 5];
pair<long long, long long> arr[1000000 + 5];
vector<long long> appr;
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n >> x;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    if (!arr[a[i]].first) arr[a[i]].first = i;
    arr[a[i]].second = i;
  }
  appr.push_back(0);
  for (long long i = 1; i <= x; i++) {
    if (arr[i].first) appr.push_back(i);
  }
  l = -1, r = n + 1;
  long long k = x;
  while (k > 1 && arr[k].second < r) {
    if (arr[k].first) r = arr[k].first;
    k--;
  }
  for (long long i = 1; i <= x; i++) {
    k = max(i, k);
    while (k != x && arr[k + 1].first < l) {
      r = arr[k + 1].second;
      k++;
    }
    if (!arr[k].first) {
      k = appr[lower_bound(appr.begin(), appr.end(), k) - appr.begin() - 1];
      k = max(i, k);
    }
    ans[i] = k;
    if (!arr[i].first) continue;
    if (arr[i].first < l) break;
    l = arr[i].second;
  }
  for (long long i = 1; i <= x; i++) {
    if (ans[i]) sum += (x - ans[i] + 1);
  }
  cout << sum << endl;
  return 0;
}
