#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-7;
int main() {
  long long int n, x;
  cin >> n >> x;
  long long int a[n];
  vector<long long int> v[x + 10];
  long long int premax[n + 10];
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    v[a[i]].push_back(i);
  }
  premax[0] = a[0];
  for (long long int i = 1; i < n; i++) {
    premax[i] = max(premax[i - 1], a[i]);
  }
  long long int p = 1;
  long long int last = n + 4;
  for (long long int i = x; i >= 1; i--) {
    if (!(long long int)v[i].size()) {
      p = i;
      continue;
    }
    if (v[i].back() > last) break;
    p = i;
    last = v[i][0];
  }
  long long int ans = 0;
  last = -1;
  for (long long int l = 1; l <= x; l++) {
    long long int r = max(l, p - 1);
    if (last != -1) {
      r = max(r, premax[last]);
    }
    ans += x - r + 1;
    if ((long long int)v[l].size()) {
      if (v[l][0] < last) break;
      last = v[l].back();
    }
  }
  cout << ans << "\n";
}
