#include <bits/stdc++.h>
using namespace std;
const int N = int(1e6) + 99;
int n, x;
int a[N];
vector<int> pos[N];
int prefMax[N];
int main() {
  scanf("%d %d", &n, &x);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    pos[a[i]].push_back(i);
    prefMax[i] = max(a[i], (i > 0 ? prefMax[i - 1] : a[i]));
  }
  int p = 1;
  int lst = n + 5;
  for (int i = x; i >= 1; --i) {
    if (pos[i].empty()) {
      p = i;
      continue;
    }
    if (pos[i].back() > lst) break;
    p = i;
    lst = pos[i][0];
  }
  long long res = 0;
  lst = -1;
  for (int l = 1; l <= x; ++l) {
    int r = max(l, p - 1);
    if (lst != -1) r = max(r, prefMax[lst]);
    res += x - r + 1;
    if (!pos[l].empty()) {
      if (pos[l][0] < lst) break;
      lst = pos[l].back();
    }
  }
  cout << res << endl;
  return 0;
}
