#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     long long int s, sum = 0;     cin >> n >> s;     long long int* v = new long long int[n];     for (int i = 0; i < n; i++) {       cin >> v[i];       sum += v[i];     }     if (s > sum)       cout << -1 << endl;     else {       sort(v, v + n);       if (s < (sum - v[0] * n))         cout << v[0] << endl;       else {         s -= sum - v[0] * n;         if (s % n == 0)           cout << v[0] - s / n << endl;         else           cout << v[0] - (s / n) - 1 << endl;       }     }   }   