#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.14159265359;
long long MOD = (long long)10883;
const long long MAXN = (long long)1e6 + 10;
const long long INF = (long long)(LONG_LONG_MAX - 3ll) / 2ll;
const long double EPS = (long double)1e-8;
long long mul(long long a, long long b) {
  return ((a % MOD) * (b % MOD)) % MOD;
}
long long pw(long long b, long long p) {
  if (p == 0) return 1;
  if (p & 1) return mul(b, pw(b, p - 1));
  return pw(mul(b, b), p / 2);
}
long long inv(long long x) { return pw(x, MOD - 2); }
long long mn[MAXN];
long long mx[MAXN];
long long psmx[MAXN];
long long psmn[MAXN];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie();
  fill(mn, mn + MAXN, INF);
  fill(mx, mx + MAXN, -1);
  long long n, x;
  cin >> n >> x;
  long long v;
  for (int i = 0; i < n; i++) {
    cin >> v;
    mn[v] = min(mn[v], (long long)i);
    mx[v] = i;
  }
  psmx[0] = -1;
  for (int i = 1; i <= x; i++) {
    if (mx[i] == -1) {
      psmx[i] = psmx[i - 1];
    } else {
      if (mn[i] <= psmx[i - 1])
        psmx[i] = INF + 2;
      else
        psmx[i] = mx[i];
    }
  }
  psmn[x + 1] = INF + 100;
  for (int i = x; i > 0; i--) {
    if (mx[i] == -1) {
      psmn[i] = psmn[i + 1];
    } else {
      if (psmn[i + 1] <= mx[i])
        psmn[i] = -2;
      else
        psmn[i] = mn[i];
    }
  }
  long long ans = 0;
  long long p1 = 1;
  for (int i = 0; i <= x; i++) {
    if (psmx[i] == INF + 2) break;
    p1 = max(p1, i + 1ll);
    while (psmn[p1] < psmx[i]) p1++;
    if (p1 == i + 1)
      ans += (x - i);
    else
      ans += (x - (p1 - 1) + 1);
  }
  cout << ans;
  return 0;
}
