#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
const double EPS = 1e-9;
void solve() {
  long long n, x;
  cin >> n >> x;
  long long a[n + 1];
  vector<long long> firstpos(x + 1, -1), lastpos(x + 1, -1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (firstpos[a[i]] == -1) {
      firstpos[a[i]] = i;
    }
    lastpos[a[i]] = i;
  }
  vector<long long> suff(x + 2, -1);
  vector<long long> pref(x + 1, -1);
  pref[0] = 0;
  suff[x + 1] = n;
  for (int i = 1; i <= x; i++) {
    if (firstpos[i] == -1) {
      pref[i] = pref[i - 1];
    } else {
      if (firstpos[i] >= pref[i - 1]) {
        pref[i] = lastpos[i] + 1;
      } else {
        break;
      }
    }
  }
  for (int i = x; i >= 1; i--) {
    if (lastpos[i] == -1) {
      suff[i] = suff[i + 1];
    } else {
      if (lastpos[i] < suff[i + 1]) {
        suff[i] = firstpos[i];
      } else {
        break;
      }
    }
  }
  auto works = [&](int l, int r) {
    return pref[l - 1] != -1 && suff[r + 1] != -1 && pref[l - 1] <= suff[r + 1];
  };
  long long ans = 0;
  for (int l = 1, r = 1; l <= x; l++) {
    if (r < l) {
      r++;
    }
    while (r <= x and !works(l, r)) {
      r++;
    }
    ans += x - r + 1;
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout.precision(50);
  solve();
}
