#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, k;
    cin >> n >> k;
    (void)k; // K = 1: the single smallest value in the array.

    vector<int> a(n);
    for (auto& x : a) cin >> x;

    int target = *min_element(a.begin(), a.end());

    // Count subarrays containing at least one occurrence of `target`
    // as (total subarrays) - (subarrays with none), where the second
    // term is a sum of L*(L+1)/2 over the gaps between consecutive
    // occurrences (and before the first / after the last).
    ll total = (ll)n * (n + 1) / 2;
    ll empty = 0;
    int last = -1;

    for (int i = 0; i <= n; i++) {
        if (i == n || a[i] == target) {
            ll len = i - last - 1;
            empty += len * (len + 1) / 2;
            last = i;
        }
    }

    cout << (total - empty) << '\n';

    return 0;
}
