#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, x;
  cin >> n >> x;
  vector<int> mn(x + 10), mx(x + 10);
  for (int i = 1, y; i <= n; ++i) {
    cin >> y;
    if (mn[y] == 0) mn[y] = i;
    mx[y] = i;
  }
  mn[0] = mx[0] = 0;
  mn[x + 1] = mx[x + 1] = 1e9;
  vector<int> nums{0};
  for (int i = 1; i <= x + 1; ++i) {
    if (mn[i]) nums.push_back(i);
  }
  int R = x;
  int idx = mn[x + 1];
  for (int y = x; y >= 1; --y) {
    if (mn[y] == 0) {
      R = y;
      continue;
    }
    if (mx[y] < idx) {
      R = y;
      idx = mn[y];
    } else
      break;
  }
  idx = mx[0];
  vector<int> mxx{0};
  for (int i = 1; i <= x; ++i) {
    if (mn[i] == 0) {
      continue;
    }
    if (mn[i] > idx) {
      idx = mx[i];
      mxx.push_back(mx[i]);
    } else
      break;
  }
  auto nxt = [&nums](int y) { return *upper_bound(begin(nums), end(nums), y); };
  long long ans = 0;
  for (int i = 1; i <= x; ++i) {
    if (i + 1 >= R) {
      int r = nxt(i);
      auto it = lower_bound(begin(mxx), end(mxx), mn[r]);
      ans += min(i, nums[it - begin(mxx)]);
    }
  }
  cout << ans << endl;
}
