#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <numeric>
#include <ctime>
#include <string>
#include <bitset>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
const ll N = 2e5 + 5, mod = 1e9 + 7, inf = 2e18;

ll a[N];
ll per[N];

void solve() {
    int n, k;
    cin >> n >> k;

    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i] -= k;
    }

    unordered_map<ll, ll> mp;

    ll ans = -1;
    for (int i = 0; i < n; ++i) {
        per[i + 1] = per[i] + a[i];
    }

    for (int i = 0; i <= n; ++i) {
        if (mp.find(per[i]) == mp.end()) {
            mp[per[i]] = i;
        } else {
            ans = max(ans, i - mp[per[i]]);
        }
    }

    cout << ans;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int t = 1;
    // cin >> t;

    while (t--) {
        solve();
    }

    return 0;
}