#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<long long>>;
const long long INF = 1LL <<59;
const long long Mo=1000000007;

vector<long long> seen;

long long dfs(const Graph &G, int v, long long cnt) {
  seen[v] = cnt;	//判定だけならcntをboolに
  // v から行ける各頂点 next_v について
  for (auto next_v : G[v]) {
    if (seen[next_v]>=0) continue; // next_v が探索済だったらスルー
    dfs(G, next_v, cnt); // 再帰的に探索
  }
  //cout<<grp<<" "<<cnt<<endl;
  return 0;
}

long long gcn(long long x,long long y){
  if(x%y==0){
    return y;
  }
  else{
    return gcn(y,x%y);
  }
}

long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
int main(void){
  long long tmp,idx,cur,prev;
  long long flg;
  long long i,j,l;
  long long n,m,k;
  long double res,tmp1,tmp2;

  cin>>n>>m>>k;
  long long a[k];
  long double dp[n+1][2]={};
  long double mm=1.0/(long double)m;
  //cout<<mm;

  for(i=0;i<k;i++){
    cin>>a[i];
  }
  sort(a,a+k);

  tmp=1;
  for(i=1;i<k;i++){
    if(a[i]-a[i-1]==1){
      tmp++;
      if(tmp==m){
        cout<<-1<<endl;
        return 0;
      }
    }
    else{
      tmp=1;
    }
  }

  tmp1=0;
  tmp2=0;

  for(i=n-1;i>=0;i--){
    flg=0;

    tmp1+=dp[i+1][0];
    tmp2+=dp[i+1][1];

    if(i+m+1<=n){
      tmp1-=dp[i+m+1][0];
      tmp2-=dp[i+m+1][1];
    }

    for(j=0;j<k;j++){
      if(i==a[j]){
        flg=1;
        break;
      }
    }
    if(flg==1){
      dp[i][1]=1;
      continue;
    }

    dp[i][0]=tmp1/m+1.0;
    dp[i][1]=tmp2/m;
  }
  //cout<<dp[0][0]<<" "<<dp[1][0]<<" "<<dp[2][0]<<endl;
  if(dp[0][1]==1){
    res=-1;
  }
  else{
    res=dp[0][0]/(1.0-dp[0][1]);
  }

  //cout<<res<<endl;
  cout<<setprecision(15)<<res<<endl;
  //cout<<res<<endl;

  return 0;
}

/*
Graph G(n);
seen.assign(n,-1);
for(i=0; i<m; i++) {
  cin>>tmp1>>tmp2;
  tmp1--;
  tmp2--;
  G[tmp1].push_back(tmp2);
  G[tmp2].push_back(tmp1);
}
*/

#include <bits/stdc++.h>

#define LL long long

#define ull unsigned long long

#define F(i, j, k) for(int i = j; i <= k; i++)

#define DF(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

template <typename T> inline void read(T &n) {
	T w = 1;
	n = 0;
	char ch = getchar();
	while (!isdigit(ch) && ch != EOF) {
		if (ch == '-') w = -1;
		ch = getchar();
	}
	while (isdigit(ch) && ch != EOF) {
		n = (n << 3) + (n << 1) + (ch & 15);
		ch = getchar();
	}
	n *= w;
}

template <typename T> inline void write(T x) {
	T l = 0;
	ull y = 0;
	if (!x) {
		putchar(48);
		return;
	}
	if (x<0) {
		putchar('-');
		x = -x;
	}
	while (x) {
		y = y * 10 + x % 10;
		x /= 10;
		l++;
	}
	while (l) {
		putchar(y % 10 + 48);
		y /= 10;
		l--;
	}
}

template <typename T> inline void writes(T x) {
	write(x);
	putchar(' ');
}

template <typename T> inline void writeln(T x) {
	write(x);
	puts("");
}

template <typename T> inline void checkmax(T &a,T b) { a = a > b ? a : b; }

template <typename T> inline void checkmin(T &a,T b) { a = a < b ? a : b; }

const int N = 2e5 + 10;

int p[N], wei[N];

struct wzy {
	long double x, c;
	wzy (long double X = 0,long double C = 0) {
		x = X;
		c = C;
	}
} f[N], g[N];

wzy operator +(const wzy x,const wzy y) { return wzy{x.x + y.x, x.c + y.c}; }

wzy operator -(const wzy x,const wzy y) { return wzy{x.x - y.x, x.c - y.c}; }

wzy operator *(const double x, const wzy y) { return wzy{x * y.x, x * y.c}; }

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	int n, k, m;
	read(n);
	read(m);
	read(k);
	F(i, 1, k)  { read(p[i]); wei[p[i]] = 1; }
	F(i, n, n + m - 1) f[i].x = 1;
	DF(i, n + m - 1, n) g[i] = g[i + 1] + f[i];
	long double changshu1 = m;
	long double changshu2 = 1 / changshu1;
	DF(i, n - 1, 0) {
		f[i] = changshu2 * (g[i + 1] - g[i + m + 1]);
		f[i].c -= 1.0;
		if (wei[i]) f[i].x = f[i].c = 0;
		g[i] = g[i + 1] + f[i];
	}
	if (f[0].x == 0) puts("-1");
	else cout << fixed << setprecision(4) << -f[0].c / f[0].x << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
using ll = long long;
const ll INF = 1e9;

int n,q;
vector<ll> a,t,x;

void solve() {
  ll s = 0, l = -INF, r = INF;
  REP(i,n) {
    if (t[i] == 1) { // +
      s += a[i];
      l += a[i];
      r += a[i];
    } else if (t[i] == 2) { // max
      l = max(l,a[i]);
      r = max(r,a[i]);
    } else { // min
      l = min(l,a[i]);
      r = min(r,a[i]);
    }
  }

  REP(i,q) {
    ll ans = x[i]+s;
    if (ans < l) ans = l;
    if (r < ans) ans = r;
    cout << ans << endl;
  }
  return;
}

int main() {
  cin >> n;
  a.resize(n);
  t.resize(n);
  REP(i,n) cin >> a[i] >> t[i];

  cin >> q;
  x.resize(q);
  REP(i,q) cin >> x[i];

  solve();
  return 0;
}

#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define umci unordered_map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define mod 998244353
using namespace std;

bool isPrime(ll n)
{
    // Corner cases
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (ll i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}
ll power(ll x,ll n)
{ll x1=0;
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x);
       //  if(result>=1000000001) return 0;
        x=(x*x);
      //   if(x>=1000000001) return 0;
        n=n/2;
    }
    return result;
}
ll countDivisors(ll n)
{
    ll cnt = 0;
    for (ll i = 1; i <= sqrt(n); i++) {
        if (n % i == 0) {

            if (n / i == i)
                cnt++;

            else
                cnt = cnt + 2;
        }
    }
    return cnt;
}
int main(){
   IOS;
ll t;t=1;

while(t--){
ll n;cin>>n;
while(n%2==0){
    n=n/2;
}
cout<<2*(countDivisors(n));

}

return 0;
}


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

int main() {
    // your code goes here
// 	int t;
// 	cin>>t;
// 	while(t--)
// 	{

// 	}
    unsigned long long int x,y,a,b,count=0;
    cin>>x>>y>>a>>b;
    while(1)
    {
        if(x*(a-1)>b)
        {
            break;
        }
        if(y<=x*a)
        break;
        x=x*a;
        count++;
    }
    if(x<y)
    count+=(y-x-1)/b;
    cout<<count<<endl;

	return 0;
}

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

int main(){
  int a,b,c,d;
  cin>>a>>b;
  cin>>c>>d;
  cout << b-c << endl;
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;

#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

constexpr int INF = 1e9+7;
constexpr ll INFL = 9*1e18;

constexpr int dx[4] = { 1, 0, -1, 0 };
constexpr int dy[4] = { 0, 1, 0, -1 };

// constexpr int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
// constexpr int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

int inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
ull inline power(ull a,ull b){ull res = 1;rep(i,b)res *= a;return res;}
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T>inline void print(T&& x){cout<<setprecision(32)<<x<<endl;}
string to_oct(int n){string s;while(n){s = to_string(n%8) + s;n /= 8;}return s;}

int main(){
  int n;cin>>n;
  string s;cin>>s;
  int q;cin>>q;
  bool reversed = false;
  rep(i,q){
    int t;cin>>t;
    int a,b;cin>>a>>b;a--;b--;
    if(reversed){
      a = (a + n) % (2*n);
      b = (b + n) % (2*n);
    }

    if(t == 1){
      swap(s[a],s[b]);
    }else{
      reversed = !reversed;
    }
  }
  if(reversed){

    string t1 = s.substr(0,n);
    string t2 = s.substr(n,2*n);
    s = t2 + t1;

  }
  print(s);

  return 0;
}

#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

std::string s;

int main(void){
	int n,i,m,t,a,b,q;
	bool flag = false;
	std::cin >> n;
	std::cin >> s;
	std::cin >> q;
	m = s.l_ength();
	for(i=0; i<q; ++i){
		std::cin >> t >> a >> b;
		--t; --a; --b;
		if(t){
			flag = (!flag);
		}else{
			a += (flag?n:0); a %= m;
			b += (flag?n:0); b %= m;
			std::swap(s[a],s[b]);
		}
	}
	for(i=0; i<m; ++i){
		std::cout << s[(flag?((i+n)%m):i)];
	}
	std::cout << std::endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long k , n , m , a [100005];
vector < long long > v;
bool ck ( long double x )
{
    v . clear ();
    long double mm = m , nn = n;
    long long mnsum = 0 , mxsum = 0;
    for ( int i = 0 ; i < k ; i ++ )
    {
        long long mn = ceil ( ( mm * a [i] - x ) / nn ) , mx = ( mm * a [i] + x ) / nn;
        mnsum += mn , mxsum += mx;
    }
    for ( int i = 0 ; i < k ; i ++ )
    {
        if ( mnsum <= mm && mm <= mxsum )
        {
            long long mn = ceil ( ( m * a [i] - x ) / nn ) , mx = ( m * a [i] + x ) / nn;
            mnsum -= mn , mxsum -= mx;
            long long vmn = mm - mxsum , vmx = mm - mnsum;
            if ( mx < vmn || vmx < mn ) return 0;
            if ( mn <= vmn && vmn <= mx )
            {
                v . push_back ( vmn );
                mm -= vmn;
                continue;
            }
            if ( mn <= vmx && vmx <= mx )
            {
                v . push_back ( vmx );
                mm -= vmx;
                continue;
            }
            if ( vmn <= mn && mn <= vmx )
            {
                v . push_back ( mn );
                mm -= mn;
                continue;
            }
            if ( vmn <= mx && mx <= vmx )
            {
                v . push_back ( mx );
                mm -= mx;
                continue;
            }
        }
        else return 0;
    }
    return 1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    cin >> k >> n >> m;
    for ( int i = 0 ; i < k ; i ++ ) cin >> a [i];
    long long l = 0 , r = 1e13 , mid;
    while ( l < r )
    {
        mid = ( l + r ) / 2;
        if ( ck ( mid ) ) r = mid;
        else l = mid + 1;
    }
    ck ( l );
    for ( int i = 0 ; i < v . size () ; i ++ ) cout << v [i] << ' ';
}

    #include "bits/stdc++.h"

    using namespace std;

    using ll = long long;
    using vll = vector<ll>;
    using vvll = vector<vector<ll>>;
    using vvvll = vector<vector<vector<ll>>>;
    using vvvvll = vector<vector<vector<vector<ll>>>>;
    using pl4 = pair<ll,ll>;
    using str = string;
    using vpl4 = vector<pair<ll,ll>>;

    #define sz size()
    #define be begin()
    #define en end()
    #define fi first
    #define se second
    #define pb push_back
    #define mp make_pair

    #define llin(x) ll (x);cin >>(x);
    #define stin(x) str (x);cin >>(x);
    #define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
    #define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
    #define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
    #define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
    #define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
    #define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
    #define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
    #define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
    #define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
    #define SORT(x) sort(x.be, x.en)
    #define rSORT(x) sort(x.rbegin(), x.rend())
    #define say(x) cout<<(x);
    #define sal(x) cout<<(x)<<endl;
    #define says(x) cout<<(x)<<(' ');
    #define sas cout<<(' ');
    #define sayR(x) cout<<fixed<<setprecision(10)<<(x);
    #define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
    #define yn(a) cout <<((a)?"yes":"no")<<endl;
    #define Yn(a) cout <<((a)?"Yes":"No")<<endl;
    #define YN(a) cout <<((a)?"YES":"NO")<<endl;
    #define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
    #define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
    #define pow(a,b) ll(pow(a,b))

    ll MOD=1000000007;
    ll INF=100000000000001;
    vector<ll> value; // ノードの値を持つ配列
    ll N;             // 葉の数

    void update(ll i, ll x) {
        // i 番目の葉の値を x に変える
        i += N - 1; // i 番目の葉のノード番号
        value[i] = x;
        while (i > 0) {
            i = (i - 1) / 2; // ノード i の親ノードの番号に変える
            value[i] = min(value[i * 2 + 1],
                        value[i * 2 + 2]); // 左右の子の min を計算しなおす
        }
    }

    ll query(ll a, ll b, ll k, ll l, ll r) {
        // [a, b) の区間に対するクエリについて
        // ノード k （区間 [l, r) 担当）が答える
        if (r <= a || b <= l) return INF; // 区間が被らない場合は INF を返す
        if (a <= l && r <= b)
            return value[k]; // ノード k の担当範囲がクエリ区間 [a, b)
                            // に完全に含まれる
        else {
            ll c1 = query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子に値を聞く
            ll c2 = query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子に値を聞く
            return min(c1, c2); // 左右の子の値の min を取る
        }
    }

    ll n;
    vvll d(200001,vll(2,0));
    vvll e(200001,vll(2,0));
    vvll a(200001,vll(2,0));
    vvll c(200001,vll(0));

long long mi(long long a) {
    ll m=MOD;
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

signed main(){
    llin(r1);
    llin(c1);
    llin(r2);
    llin(c2);
    ll x=abs(r1-r2);
    ll y=abs(c1-c2);
    if(x==0&&y==0){
        sal(0);
        return 0;
    }
    if(x-y==0||x+y<=3){
        sal(1);
        return 0;
    }
    if((x-y)%2==0||abs(x-y)<=3){
        sal(2);
        return 0;
    }
    sal(3);
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;
long double pi = acos(-1);

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll k,n,m;
    cin>>k>>n>>m;
    ll a[k];
    for(int i=0;i<k;i++)cin>>a[i];
    array<ll,2> ans[k]={};
    ll sum = 0;
    array<ll,2> dif[k]={};
    for(int i=0;i<k;i++){
        ans[i][0] = m*a[i]/n;
        ans[i][1]=i;
        sum += ans[i][0];
        dif[i][1]=i;
        dif[i][0] = abs(n*(ans[i][0]+1LL)-m*a[i]) - abs(n*ans[i][0]-m*a[i]);
    }
    ll rem = m - sum;
    sort(dif,dif+k);
    ll ret[k]={};
    for(int i=0;i<rem;i++){
        ret[dif[i][1]]++;
    }
    for(int i=0;i<k;i++)ret[ans[i][1]]+=ans[i][0];
    for(int i=0;i<k;i++){
        cout << ret[i] << " ";
    }
    cout << endl;
}

#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <iostream>
#define ll long long
using namespace std;
int k;ll n,m,a[100010],ans[100010],l[100010],r[100010],le,ri;
bool check(ll x)
{
	le=0,ri=0;
	for(int i=1;i<=k;i++)
	{
		r[i]=(x+a[i])/n;
		if(a[i]<=x) l[i]=0;
		else l[i]=((a[i]-x)%n==0)?(a[i]-x)/n:(a[i]-x)/n+1;
		le+=l[i],ri+=r[i];
		if(r[i]<l[i])
			return false;
	}
	if(le>m||ri<m) return false;
	for(int i=1;i<=k;i++)
	{
		if(r[i]-l[i]+le<=m)
			ans[i]=r[i],le+=r[i]-l[i];
		else
			ans[i]=l[i]+m-le,le=m;
	}
	return true;
}
int main()
{
	scanf("%d %lld %lld",&k,&n,&m);
	for(int i=1;i<=k;i++)
		scanf("%lld",&a[i]);
	for(int i=1;i<=k;i++)
		a[i]*=m;
	ll l=0,r=1e18;
	while(l<=r)
	{
		ll mid=l+r>>1;
		if(check(mid))
			r=mid-1;
		else
			l=mid+1;
	}
	for(int i=1;i<=k;i++)
		printf("%lld ",ans[i]);
}


//Never stop trying
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;
typedef pair<int, int> pi;
#define fi first
#define se second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<str> vs;
typedef vector<ld> vd;
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

const int MOD = 1e9 + 7; //998244353
const ll INF = 1e18;
const int MX = 2e5 + 10;
const int nx[4] = {0, 0, 1, -1}, ny[4] = {1, -1, 0, 0}; //right left down up

template<class T> using V = vector<T>;
template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

ll cdiv(ll a, ll b) { return a / b + ((a ^ b) > 0 && a % b); } // divide a by b rounded up
constexpr int log2(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))

#define dbg(x) cerr << " - " << #x << " : " << x << endl;
#define dbgs(x,y) cerr << " - " << #x << " : " << x << " / " << #y << " : " << y << endl;
#define dbgv(v) cerr << " - " << #v << " : " << endl << "[ "; for(auto it : v) cerr << it << ' '; cerr << ']' << endl;

void IO() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int power[4000009];

int32_t main() {
	boost; IO();

	power[0]=1;
	FOR(i,1,4000009) power[i]=(power[i-1]*2)%MOD;

	int N,M; cin>>N>>M;
	char g[N][M];
	int a[N][M],b[N][M],c[N][M],d[N][M];

	int K=0;
	FOR(i,0,N) FOR(j,0,M){
		cin>>g[i][j];
		if(g[i][j]=='.') K++;
	}

	//L
	FOR(i,0,N) FOR(j,0,M){
		if(g[i][j]=='#'){
			a[i][j]=0;
			continue;
		}
		a[i][j]=1;
		if(j) a[i][j]+=a[i][j-1];
	}

	//R
	FOR(i,0,N) ROF(j,0,M){
		if(g[i][j]=='#'){
			b[i][j]=0;
			continue;
		}
		b[i][j]=1;
		if(j+1<M) b[i][j]+=b[i][j+1];
	}

	//U
	FOR(j,0,M) FOR(i,0,N){
		if(g[i][j]=='#'){
			c[i][j]=0;
			continue;
		}
		c[i][j]=1;
		if(i) c[i][j]+=c[i-1][j];
	}
	FOR(j,0,M) ROF(i,0,N){
		if(g[i][j]=='#'){
			d[i][j]=0;
			continue;
		}
		d[i][j]=1;
		if(i+1<N) d[i][j]+=d[i+1][j];
	}

	/*FOR(i,0,N){
		FOR(j,0,M)
			cout << d[i][j] << ' ';
		cout << endl;
	}*/

	int ans=0;
	FOR(i,0,N) FOR(j,0,M)if(g[i][j]=='.'){
		int y=a[i][j]+b[i][j]+c[i][j]+d[i][j]-3;
		//cout << y << endl;
		int x=power[y]-1;
		x%=MOD;
		//cout << x << endl;
		x*=power[K-(y)];
		x%=MOD;
		ans+=x; ans%=MOD;
	}
	cout << ans << endl;

	return 0;
}

/* Careful!!!
	.Array bounds
	.Infinite loops
	.Uninitialized variables / empty containers
	.Order of input

   Some insights:
	.Binary search
	.Graph representation
	.Write brute force code
	.Change your approach
*/

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

char c[2005][2005];
int a[2005][2005];
int b[2005][2005];
int d[2005][2005];

int main(){
  int h, w; cin >> h >> w;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> c[i][j];
    }
  }
  for(int i = 0; i < h; i++){
     int now = 0;
    for(int j = 0; j < w; j++){
      if(c[i][j]=='.'){
        now++;
        a[i][j] = now;
      }
      if(c[i][j]=='#'){
        now = 0;
        a[i][j] = 0;
      }
    }
  }
  for(int i = 0; i < h; i++){
    int now = 0;
    for(int j = w-1; j>=0; j--){
      if(a[i][j]==0)now = 0;
      if(a[i][j]>0){
        now = max(now,a[i][j]);
        a[i][j] = now;
      }
    }
  }

  for(int i = 0; i < w; i++){
     int now = 0;
    for(int j = 0; j < h; j++){
      if(c[j][i]=='.'){
        now++;
        b[j][i] = now;
      }
      if(c[j][i]=='#'){
        now = 0;
        b[j][i] = 0;
      }
    }
  }
  for(int i = 0; i < w; i++){
    int now = 0;
    for(int j = h-1; j>=0; j--){
      if(b[j][i]==0)now = 0;
      if(b[j][i]>0){
        now = max(now,b[j][i]);
        b[j][i] = now;
      }
    }
  }
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(c[i][j]=='.')d[i][j] = a[i][j] + b[i][j] -1;
    }
  }
  ll sum = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(c[i][j]=='.')sum ++;
    }
  }
  mint ans = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(c[i][j]=='.') {
        mint now = 1;
        now *= mint(2).pow(d[i][j])-1;
        now *= mint(2).pow(sum-d[i][j]);
        ans += now;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define INF 1000000007
#define MOD 998244353
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

mt19937_64 rnd(time(NULL));

struct UnionFind {
	vector<int> par, depth, sz;
	UnionFind(int n) : par(n+1), depth(n+1), sz(n+1){
		for(int i = 0; i <= n; i++){
			par[i] = i;
			depth[i] = 0;
			sz[i] = 1;
		}
	}
	int find(int x){
		if(par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		sz[x] += sz[y];
		sz[y] = sz[x];
		if(depth[x] < depth[y]){
			par[x] = y;
		}
		else{
			par[y] = x;
			if(depth[x] == depth[y]) depth[x]++;
		}
	}
	bool same(int x, int y){
		return find(x) == find(y);
	}
	int size(int x){
		return sz[find(x)];
	}
};
i64 n, x[101], y[101];
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> x[i] >> y[i];
		x[i] += 100;
		y[i] += 100;
	}

	double l = 0, r = 200;
	for(int i = 0; i < 100; i++){
		double c = (l+r)/2;
		UnionFind uf(n+2);
		for(int j = 0; j < n; j++){
			if(y[j] < c) uf.unite(j,n);
			if(200-y[j] < c) uf.unite(j,n+1);

			for(int k = 0; k < n; k++){
				if(pow(pow(x[j]-x[k],2)+pow(y[j]-y[k],2),0.5) < c){
					uf.unite(j,k);
				}
			}
		}
		bool ok = 1;
		for(int i = 0; i < n; i++){
			if(uf.same(i,n) && uf.same(i,n+1)) ok = 0;
		}
		if(uf.size(0) == n+2 || !ok) r = c;
		else l = c;
	}
	printf("%.10f\n", r/2);
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}

	return 0;
}

//#include <atcoder/all>
#include <bits/stdc++.h>
#include <cassert>
#include <numeric>
using namespace std;
//using namespace atcoder;
typedef  long long LONG;
const int MOD = 1000000007;

int gcd(int x, int y) {
	if (x % y == 0) {
		return y;
	}
	else {
		return gcd(y, x % y);
		//x%y==0でないときはユーグリットの互除法を使って再帰的に関数を呼び出す。
	}
}
LONG pow2(long long x, long long n) {
	long long ret = 1;
	while (n > 0) {
		if (n & 1) ret = ret * x % MOD;  // n の最下位bitが 1 ならば x^(2^i) をかける
		x = x * x % MOD;
		n >>= 1;  // n を1bit 左にずらす
	}
	return (int)ret;
}
void printVector(const vector<int>& vec) {
	for (int value : vec) {
		cout << value << " ";
	}
	cout << endl;
}
LONG t(LONG N,LONG i) {
	return N - abs(i);
}
int count(vector<int>&a, int s) {
	int result = 0;
	for (int i = 0; i < a.size(); i++) {
		if (a[i] == s) {
			result++;
		}
	}
	return result;
}

LONG kaizyo(int N) {
	LONG result = 1;
	LONG mod = 998244353;

	for (LONG i = 2; i <= N; i++) {
		result *= i;
		result = result % mod;
	}
	return result;
}
class Point {
public:
	int x;
	int y;
};
LONG stock[3500][3500];
LONG test(int N, int task) {
	LONG mod = 998244353;
	if (N < task)return 0;
	if (N < 0)return 0;
	if (task == 0) {
		if (N == 0) {
			return 1;
		}
		else {
			return 0;
		}

	}

	if (stock[N][task] > 0)return stock[N][task];
	stock[N][task] =( test(N - 1, task - 1) + test(N, task * 2)) % mod;

	return stock[N][task]%mod ;
}
class DP {
public:
	DP() {

	}
	DP(int a, int b) {
		other = a;
		path = b;

	}
	int other;
	int path;
};

void dp(vector<vector<DP>>& list, vector<int> &able, int pos,int limit) {
	for (int i = 0; i < list[pos].size(); i++) {
		if (list[pos][i].path <= limit) {
			if (able[list[pos][i].other] == 0) {
				able[list[pos][i].other] = 1;
				dp(list, able, list[pos][i].other, limit);
			}
		}
	}
}
int main() {

	LONG N;
	cin >> N;
	vector<Point>P(N);
	for (int i = 0; i < N; i++) {
		cin >>P[i].x>>P[i].y;
	}
	vector<vector<DP>>d(N+2, vector<DP>(0));

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < i; j++) {

			int r = (P[i].x - P[j].x)*(P[i].x - P[j].x) + (P[i].y - P[j].y)*(P[i].y - P[j].y);
			if (r < 40000) {
				d[i+2].push_back(DP(j+2, r));
				d[j+2].push_back(DP(i+2, r));
			}
		}
	}
	for (int i = 0; i < N; i++) {
		d[i+2].push_back(DP(0, (100-P[i].y)* (100 - P[i].y)));
		d[0].push_back(DP(i+2, (100 - P[i].y)*(100-P[i].y)));
	}
	for (int i = 0; i < N; i++) {
		d[i + 2].push_back(DP(1, (-100 - P[i].y)* (-100 - P[i].y)));
		d[1].push_back(DP(i + 2, (-100 - P[i].y)* (-100 - P[i].y)));
	}
	d[0].push_back(DP(1, 40000));
	d[1].push_back(DP(0, 40000));
	int max = 40000;
	int min = 0;
	int mid = (max) / 2;
	while (max - min > 1) {
		bool frag = false;
		vector<int> able(N + 2, 0 );//未到達は0、到達は1
		able[0] = 1;
		dp(d, able, 0, mid);
		if (able[1] == 1) {
			max = mid;
			mid = (max + min) / 2;
		}else{
			min = mid;
			mid = (max + min) / 2;
		}
//		cout << max<<"\t" << min << "\t" << mid << "\n";
	}
	cout << std::fixed << std::setprecision(15) << sqrt(mid+1)/2.0;

	return 0;
}


#include <bits/stdc++.h>
#define int long long
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
const long long INF = 1e18;
const long long MOD = 998244353;

void solve()
{
    int n, x;
    cin >> n >> x;
    string s;
    cin >> s;

    int now = x;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'o')
            now += 1;
        else
            now = max((int)0, now - 1);
    }
    cout << now << endl;
}

signed main()
{
    solve();
    return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(){
    int a,b;
    cin >> a >> b;
    int ans=2*a+100-b;
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
  long long int n;
 cin>>n;
 long long int arr[n],ans=0,temp=0;
  for(int i=0;i<n;i++)
    cin>>arr[i];

  sort(arr,arr+n);
  for(int i=0;i<n;i++)
  {
   ans+=arr[i]*i-temp;
    temp+=arr[i];
  }
  cout<<ans<<endl;
}

#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  for(int i=0; i<N; i++) cin >> p[i];

  vector<bool> ans(210000, true);
  int cur = 0;
  for (int i = 0; i < N; i++) {
    ans[p[i]] = false;
    for (; cur <= 210000; cur++) {
      if (ans[cur]) {
        cout << cur << endl;
        break;
      }
    }
  }
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,m;
long long sam;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	{
		sam+=i*100+j;
	}
	cout<<sam;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int32_t main()
{
	//freopen("input.txt", "r", stdin);
	IOS;

	int a; cin >> a;
	int b; cin >> b;

	for(int i = -100 ; i <= 100 ; i++)
	{
		for(int j = -100 ; j <= 100 ; j++)
		{
			if(i+j == a && i-j == b)
			{
				cout << i << ' ' << j << '\n';
				return 0;
			}
		}
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
const int R=2e5 + 5;
const int N=1e5 + 3;
const int M = 2e3 + 3;
const int INF=0x3f3f3f3f;
struct edge{
	int v,w,next;
}e[R*2];
int dis[N],head[2*N],cnt=0;
int a[M][M];
struct node{
	int u,d;
	bool operator <(const node&rhs) const{
	  return d>rhs.d;
	}
};
inline void addedge(int u,int v,int w){
	e[++cnt].v=v;
	e[cnt].w=w;
	e[cnt].next=head[u];
	head[u]=cnt;
}
int n,m,s;
inline void Dij(){
	for(int i=1;i<=n;i++) dis[i]=INF;
	dis[s]=0;
	priority_queue<node> Q;
	Q.push((node){s,0});
	while(!Q.empty()){
		node fr=Q.top();Q.pop();
		int u=fr.u,d=fr.d;
		if(d!=dis[u]) continue;
		for(int i=head[u];i;i=e[i].next){
			int v=e[i].v,w=e[i].w;
			if(dis[u]+w<dis[v]){
				dis[v]=dis[u]+w;
				Q.push((node){v,dis[v]});
			}
		}
	}
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int x,y,z;
		cin>>x>>y>>z;
		if(!a[x][y]) a[x][y] = z;
		a[x][y] = min(a[x][y], z);
		addedge(x,y,z);
	}
	for(int i = 1; i <= n; ++i) {
		s = i;
		Dij(); int ans = -1;
		for(int j = 1; j <= n; ++j) if(dis[j] != INF && a[j][i]) {
			if(ans == -1) ans = dis[j] + a[j][i];
			ans = min(ans, dis[j] + a[j][i]);

		}
		cout << ans << endl;
	}
	return 0;
}

#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (decltype(end) i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (decltype(end) i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (decltype(beg) i = beg; end <= i; i--)
#define REP(n)              for (decltype(n) repeat_index = 0; repeat_index < n; repeat_index++)

using namespace std;

template<typename T, size_t S>
T minval(const T(&vals)[S])
{
	T val = numeric_limits<T>::max();
	FOR_LT(i, 0, S) {
		val = min(val, vals[i]);
	}
	return val;
}

template<typename T, size_t S>
T maxval(const T(&vals)[S])
{
	T val = numeric_limits<T>::min();
	FOR_LT(i, 0, S) {
		val = max(val, vals[i]);
	}
	return val;
}

struct E {
	int i;
	int c;
};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n, m; cin >> n >> m;
	vector<vector<E>> es(n + 1);
	REP(m) {
		int a, b, c; cin >> a >> b >> c;
		es[a].push_back({ b, c });
	}

	vector<int64_t> cs(n + 1);
	FOR_LE(i, 1, n) {
		FOR_LE(j, 1, n) {
			cs[j] = INT64_MAX;
		}

		using S = std::pair<int, int>;
		auto cmp = [](const S& lhs, const S& rhs) { return lhs.second > rhs.second; };
		priority_queue<S, vector<S>, decltype(cmp)> s(cmp);

		s.push({i, 0});
		cs[i] = 0;

		bool has_goal = false;
		while (!s.empty()) {
			S c = s.top();
			s.pop();
			if (c.first == i && c.second != 0) {
				cout << c.second << endl;
				has_goal = true;
				break;
			}
			if (cs[c.first] < c.second) continue;

			cs[c.first] = c.second;
			for (auto& e : es[c.first]) {
				//cout << e.i << " " << c.second + e.c << endl;
				s.push({ e.i, c.second + e.c });
			}
		}

		if (!has_goal) {
			cout << -1 << endl;
		}
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef pair<ll, ll> P;

const int mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;

int main()
{
    int n; cin >> n;
    int a[n];
    int lim = 0;
    rep(i,n){
        cin >> a[i];
        lim = max(lim,a[i]);
    }
    int cnt = 0;
    int ans = 0;
    for(int i = 2; i <= lim; i++){
        int tmp_cnt = 0;
        for(int j = 0; j < n; j++){
            if(a[j] % i == 0) tmp_cnt++;
        }
        if(cnt < tmp_cnt){
            cnt = tmp_cnt;
            ans = i;
        }
    }
    cout << ans << endl;
}

//#pragma GCC optimize ("O2")
//#pragma GCC optimize ("Ofast")
// IN THE NAME OF GOD
#include <bits/stdc++.h>
using namespace std;
typedef pair <int, int> pii;

template <typename Head>
inline void dout(Head in) {
  cerr << in << '\n';
}

int main() {
  ios::sync_with_stdio(false), cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    if (n % 2 == 0) {
      if (n % 4 == 0) {
        cout << "Even\n";
      }
      else {
        cout << "Same\n";
      }
    }
    else {
      cout << "Odd\n";
    }
  }
  return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <functional>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <bitset>
#include <cassert>
#include <math.h>
#include <complex>
#include <iomanip>
#include <unordered_map>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#ifdef _OLIMPOLOCAL
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 1337
#endif
void debug_out() { cout << "\n";}
template<typename T1, typename... T2> void debug_out(T1 A, T2... B) { cout << " " << A; debug_out(B...); }
int test = 1;
#define out(x) {cout << x << "\n";return;}
#define all(N) N.begin(),N.end()
#define allr(N) N.rbegin(),N.rend()
template<typename T1>
void print(vector<T1> V, int add = 0, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = V.size() - 1;
    for (int i = start; i <= end; i++) {
        cout << V[i] + add << ((i == end) ? "\n" : " ");
    }
}
template<typename T1>
T1 chmin(T1 &x, const T1 v) { return x = min(x,v); }
template<typename T1>
T1 chmax(T1 &x, const T1 v) { return x = max(x,v); }
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repsr(i, s, n) for (int i = n-1; i >= s; i--)
//-------------------------- ^ DONT TOUCH ^-----------------------------------------------------------------
#define MAX 1001
#define MOD 1000000007ll

ll n, m, q, x, y;
void solve() {
    cin >> n >> x;
    vector<int> N;
    rep(i,n) {
        cin >> y;
        if (x != y)
            N.push_back(y);
    }
    print(N);
}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int test = 1;
    #ifdef _OLIMPOLOCAL
        cin >> test;
    #endif
    rep(testCase, test) {
        #ifdef _OLIMPOLOCAL
            cout << "------------------ TESTCASE: " << testCase << " -------------\n";
        #endif
        solve();
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll> ;
#define rep(i,n) for(ll i=0;i<(n);i++)
ll min(ll a,ll b){return a>=b ? b:a;}
ll max(ll a,ll b){return a>=b ? a:b;}
int main(){
    ll n;
    cin >> n;
    vector<P> X(n);
    vector<P> Y(n);
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        X[i].first=x;
        X[i].second=i;
        Y[i].first=y;
        Y[i].second=i;
    }
    sort(X.begin(),X.end());
    sort(Y.begin(),Y.end());
    vector<ll> M(3,0);
    vector<ll> S(3);
    for (ll i=1;i>=0;i--){
        for (ll j=n-2;j<n;++j){
            if (M[0]<=abs(X[i].first-X[j].first)){
                copy(M.begin(),M.end(),S.begin());
                M[0]=abs(X[i].first-X[j].first);
                M[1]=X[i].second;
                M[2]=X[j].second;
            }else if (S[0]<=abs(X[i].first-X[j].first)){
                S[0]=abs(X[i].first-X[j].first);
                S[1]=X[i].second;
                S[2]=X[j].second;
            }
            if (M[0]<=abs(Y[i].first-Y[j].first)){
                if (M[1]==Y[i].second && M[2]==Y[j].second) continue;
                copy(M.begin(),M.end(),S.begin());
                M[0]=abs(Y[i].first-Y[j].first);
                M[1]=Y[i].second;
                M[2]=Y[j].second;
            }else if (S[0]<abs(Y[i].first-Y[j].first)){
                S[0]=abs(Y[i].first-Y[j].first);
                S[1]=Y[i].second;
                S[2]=Y[j].second;
            }
        }
    }
    cout << S[0] << endl;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

set<int> stepped;
int t[50][50];
int p[50][50];
int s=0;
int i,j;
char randstep()
{
    vector<char> ds;
    if (i>0 && !stepped.count(t[i-1][j])) ds.push_back('U');
    if (i<49 && !stepped.count(t[i+1][j])) ds.push_back('D');
    if (j>0 && !stepped.count(t[i][j-1])) ds.push_back('L');
    if (j<49 && !stepped.count(t[i][j+1])) ds.push_back('R');
    if (ds.empty()) return '#';
    char w=ds[rand()%ds.size()];
    if (w=='U') i--;
    if (w=='D') i++;
    if (w=='L') j--;
    if (w=='R') j++;
    s+=p[i][j];
    stepped.insert(t[i][j]);
    return w;

}

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    int si,sj;cin>>si>>sj;
    for (int x=0;x<50;x++){
        for (int y=0;y<50;y++){
            cin >> t[x][y];
        }
    }
    for (int x=0;x<50;x++){
        for (int y=0;y<50;y++){
            cin >> p[x][y];
        }
    }
    int ntries=20;
    srand(42);
    vector<char> bestrun;
    vector<char> attempts[ntries];
    int satts[ntries];
    int best=0;
    set<int> cache={t[si][sj]};
    while (randstep()!='#'){
        for (int k=0;k<ntries;k++){
            s=0;
            i=si;
            j=sj;
            attempts[k].clear();
            stepped=cache;
            char c=randstep();
            while (c!='#'){
                attempts[k].push_back(c);
                c=randstep();
            }
            satts[k]=s;
        }
        long tot[4];
        for (int k=0;k<4;k++) tot[k]=0;
        for (int k=0;k<ntries;k++){
            if (attempts[k][0]=='U') tot[0]+=satts[k];
            if (attempts[k][0]=='D') tot[1]+=satts[k];
            if (attempts[k][0]=='L') tot[2]+=satts[k];
            if (attempts[k][0]=='R') tot[3]+=satts[k];
        }
        int bd=0;
        for (int k=1;k<4;k++){
            if (tot[k]>tot[bd]) bd=k;
        }
        if (bd==0){
            si--;
            cache.insert(t[si][sj]);
            bestrun.push_back('U');
        }
        if (bd==1){
            si++;
            cache.insert(t[si][sj]);
            bestrun.push_back('D');
        }
        if (bd==2){
            sj--;
            cache.insert(t[si][sj]);
            bestrun.push_back('L');
        }
        if (bd==3){
            sj++;
            cache.insert(t[si][sj]);
            bestrun.push_back('R');
        }
        i=si;
        j=sj;
        stepped=cache;
    }
    for (int k=0;k<bestrun.size();k++){
        cout << bestrun[k];
    }
    cout << endl;
    //cout << s << endl;
    return 0;
}

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//#define SOME_TESTCASE
//#define MOD 998244353LL

#if 1 //テンプレ折り畳み//テンプレ折り畳み//テンプレ折り畳み

#ifdef _DEBUG
#define debug() if(true)
#define dout cout
#define dvout(v) __vout(v)
#define dvvout(v) __vvout(v)
#else
#define debug() if (false)
#define dout if(false)cout
#define dvout(v) if(false)__vout(v)
#define dvvout(v) if(false)__vvout(v)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)//rep
#define repll(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; ++i)//rep
#define repi(i, n1, n) for(int i=n1, i##_len=(n); i<i##_len; ++i)//rep
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)//自然数rep
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)

#define dxout(x) dout<<#x<<":"<<x<<_s//変数デバッグ出力
#define dxoutln(x) dout<<#x<<":"<<x<<_n
#define _Yes {cout<<"Yes"<<endl; return;}//出力
#define _No {cout<<"No"<<endl;return;}
#define _ans {cout<<ans<<endl;return;}
#define _endout(s) {cout<<(s)<<endl;return;}

#define vecvec(v, n, m) vector<vector<int>> v(n, vector<int>(m));
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vc> vvc;
#define vin(v) for (auto &i : (v)) cin >> i; //配列入力
#define vvin(v) for(auto&i:(v))for(auto&j:i)cin>>j;
#define __vout(v) {for(auto&i:(v)){cout<<i<<' ';}cout<<"\n";}
#define __vvout(v) {for(auto&i:(v)){for(auto&j:i){cout<<j<<'\t';}cout<<"\n";}cout<<"\n";}

#define INF (INT_MAX/3)
#define INFLL (LLONG_MAX/3)

#ifndef MOD
#define MOD ((ll)(1e9+7))//mod用定数 (ll)(1e9+7)
#endif
#define mod(n) ( ((ll)n) % MOD)
#define modp(n, p) ( ((ll)n) % (ll)(p))
#define modx(A,B) mod(mod(A)*mod(B))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define next asdnext
#define prev asdprev
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"
#define _s " "
#define _output dout<<"output:";
#define _here dout<<"here"<<_n;

void test();

#endif //テンプレ折り畳み

//	LLONG_MAX 9.2*1e18	9223372036854775807LL = (2^63)-1
//	INT_MAX 2.1*1e9 2147483647 = (2^31)-1
//	O(1e8) 1.2sec

vvi visited(52, vi(52,1));
vvi t(52, vi(52, -1));
int p[52][52]={};
ll score=0;
int x,y;

int arrow[4][2]={{1,0},{-1,0},{0,1},{0,-1}};//D,U,R,L
enum{
	D=0,
	U=1,
	R=2,
	L=3
};

void visit(int x, int y){
	visited[x][y]=1;
	score+=p[x][y];
	if(t[x-1][y] == t[x][y])visited[x-1][y]=1;
	else if(t[x+1][y] == t[x][y])visited[x+1][y]=1;
	else if(t[x][y-1] == t[x][y])visited[x][y-1]=1;
	else if(t[x][y+1] == t[x][y])visited[x][y+1]=1;
}

bool visitable(int v){
	return !visited[ (x+arrow[v][0]) ][ (y+arrow[v][1]) ];
}

bool move(int v){
	if(!visitable(v)) return false;

	visit( (x+=arrow[v][0]) , (y+=arrow[v][1]) );
	if(v==0)cout<<'D';
	if(v==1)cout<<'U';
	if(v==2)cout<<'R';
	if(v==3)cout<<'L';
	return true;
}

//solve//solve//solve//solve//solve//solve//solve//solve
void solve(){
	cin>>x>>y;
	x++;y++;

	reps(i,50){
		reps(j,50){
			int c;
			cin>>c;
			t[i][j]=c;
		}
	}

	reps(i,50){
		reps(j,50){
			int c;
			cin>>c;
			p[i][j]=c;
		}
	}
	reps(i,50){
		reps(j,50){
			visited[i][j]=0;
		}
	}

	visit(x,y);

	while(1){
		bool flag=0;
		rep(i,4){
			flag|=move(i);
			if(flag)break;
		}
		if(!flag)break;
	}
	cout<<_n;
	dout<<"score"<<score;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(20);
#ifdef SOME_TESTCASE
	int t = 0;
	cin >> t;
	rep(i, t) solve();
#else
	solve();
#endif
	return 0;
}

void test(){
}


#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;

int main() {
  ll N;
  cin >> N;
  ll cnt=N;
  for (int i=0;i<70;i++) {
    if (N<pow(2,i)) {
      break;
    }
    else {
    ll a=N/pow(2,i);
    ll c=a*pow(2,i);
    ll b=N-c;
    if ((a+i+b)<cnt) {
      cnt=a+i+b;
    }
    }
  }
  cout << cnt << endl;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{

       long long x,a,bb,cc;
        int count=0, arr[65], b[65], kaam=0;
        long long c[65];
        cin>>x;
       for(int i=0; x!=0; i++)
       {
           arr[i]=x%2;
           x=x/2;
           count++;
           if(arr[i]==1)
           b[kaam++]=i;
       }
       if(kaam!=1)
       {
       for(int i=0; i<kaam-1;i++)
       {
           cc=bb=a=0;
           for(int j=0; j<=i; j++)
           {
              cc+=pow(2, b[j]);
           }
          bb=b[i+1];
           for(int j=i+1; j<kaam; j++)
           {
               a+=pow(2, b[j]-b[i+1]);
           }
           c[i]=cc+bb+a;
       }

       sort(c, c+kaam-1);
       }
       else
       {
         c[0]=1+b[0];
       }
       cout<<c[0];

    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << 21 - a - b - c << endl;
    return 0;
}

#include <iostream>
#include <vector>

using namespace std;
using llint = long long;
#define rep(i,n) for(int i=0;i<(n);++i);

int main() {
  llint a,b,c;
  cin >> a >> b >> c;
  cout << (7-a) + (7-b) + (7-c) << endl;
  return 0;
}


#include <bits/stdc++.h>

typedef long double ld;
#define int unsigned long long

#define gcd            __gcd
#define endl           "\n"
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define pb             push_back
#define all(x)         x.begin(), x.end()
#define f              first
#define s              second
#define lb             lower_bound
#define ub             upper_bound
#define ins            insert
#define sz(x)          (int)(x).size()
#define mk             make_pair
#define deci(x, y)     fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define PI             3.141592653589793238
#define mem0(x)        memset(x,0,sizeof x)
#define mem1(x)        memset(x,-1,sizeof x)
using namespace std;
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.f << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NITIN
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

void solve() {
    int n;
    cin>>n;
    int x=3;
    int a=1,b=1;
    while(x<inf){
        int y=5;
        b=1;
        while(y<inf){
            if(x+y==n){
                cout<<a<<" "<<b<<endl;
                exit(0);
            }
            y*=5;
            b++;
        }
        x*=3;
        a++;
    }
    cout<<-1<<endl;
}

int32_t main() {
    nitin;

    solve();
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <list>
#include <cstdlib>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;

#define MOD 1000000007
#define PI 3.1415926535897932
#define rep(i, n) for (int i = 0; i < n; i++)
#define repe(i, j, n) for (int i = j; i < n; i++)
#define repi(i, n) for (int i = 0; i <= n; i++)
#define repie(i, j, n) for (int i = j; i <= n; i++)
#define all(x) x.begin(), x.end()
#define println() cout << endl
#define P pair<int, int>
#define fi first
#define se second

typedef long long ll;

long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

ll gcd(ll a, ll b) {
    if(a%b) {
        return gcd(b, a%b);
    } else {
        return b;
    }
}

void solve1() {
    int n; cin >> n;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
    }

    ll ans;
    if(n > 1) {
    ans = gcd(a[0], a[1]);
    for(ll i = 2; i < n; i++) {
        ans = gcd(ans, a[i]);
    }
    } else {
        ans = a[0];
    }

    cout << ans << endl;
}

int main()
{
    solve1();
}


#include <bits/stdc++.h>
#include <cassert>
#define rep(i, N) for (int i = 0; i < (N); ++i)
#define rep2(i, a, b) for (ll i = a; i <= b; ++i)
#define rep3(i, a, b) for (ll i = a; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(c) begin(c), end(c)
#define ok() puts(ok ? "Yes" : "No");
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll, ll>;
template <class T> void takeUnique(vector<T> &v) {
  auto last = std::unique(v.begin(), v.end());
  v.erase(last, v.end());
}
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int dxx[] = {0, 1, 1, 1, 0, -1, -1, -1};
int dyy[] = {1, 1, 0, -1, -1, -1, 0, 1};
// clang++ -std=c++11 -stdlib=libc++

int main() {
  int v, t, s, d;
  cin >> v >> t >> s >> d;
  bool ok = false;
  if (d < t * v || d > s * v)
    ok = true;
  ok();
  return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007

using namespace std;

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll v, a, b, d; cin >> v >> a >> b >> d;

	a *= v , b *= v;

	if (a <= d && d <= b)
		cout << "No\n";
	else
		cout << "Yes\n";
	return 0;

}


//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;

#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

//引用元
//http://drken1215.hatenablog.com/entry/2019/03/03/224600
//union くっつける
//find  どのグループか調べる
struct UnionFind {
    vector<LL> parent;

    UnionFind(LL n) : parent(n, -1) { }
    void init(LL n) { parent.assign(n, -1); }

    //xの属している木の根っこを返す
    LL root(LL x) {
        if (parent[x] < 0) return x;
        else return parent[x] = root(parent[x]);//経路圧縮
    }

    LL size(LL x) {return -parent[root(x)];}//xの属する木の要素数を求める
    bool is_same_tree(LL x,LL y) {return root(x)==root(y);}

    bool merge(LL x,LL y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (parent[x] > parent[y]) swap(x, y);//xの親の方がyの親より小さくなるようにする
        parent[x] += parent[y];//経路の長さを加算
        parent[y] = x;//yの親をxとする
        return true;
    }
};

LL N,M;
LL U[200000],V[200000],C[200000];

LL ans[200001];

vector<vector<pair<LL,LL>>> adj;
void rec(LL now_node=1,LL prev_node=-1){
    for(auto next:adj[now_node]){
        LL next_node = next.first;
        LL edge_num = next.second;
        if(next_node!=prev_node){
            if(ans[now_node]==edge_num){
                if(ans[now_node]==1) ans[next_node] = 2;
                else ans[next_node] = 1;
            }else{
                ans[next_node] = edge_num;
            }
            rec(next_node,now_node);
        }
    }
}

void solve(){
    UnionFind uf(N+1);
    //i->jの辺が存在して、それの番号がcならadj[i]はpair(j,c)を含む
    adj = vector<vector<pair<LL,LL>>>(N+1);
    for(int i=0;i<M;i++){
        if(!uf.is_same_tree(U[i],V[i])){
            uf.merge(U[i],V[i]);
            adj[U[i]].push_back(pair<LL,LL>(V[i],C[i]));
            adj[V[i]].push_back(pair<LL,LL>(U[i],C[i]));
        }
    }
    ans[1] = 1;
    rec();
}

int main(){
    cin >> N >> M;
    for(int i=0;i<M;i++){
        LL u,v,c; cin >> u >> v >> c;
        U[i] = u;
        V[i] = v;
        C[i] = c;
    }

    solve();

    for(int i=1;i<=N;i++) cout << ans[i] << endl;
    return 0;
}

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7
#define INF LONG_MAX/3
#define bit(n) (1LL<<(n))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

// pos, label
vector<pair<ll, ll> > to[100005];
ll ans[100005];

	ll N, M;

	void dfs(ll cur, ll pare, bool done) {
		if(ans[cur] != -1) return;
		if(done) {
			ans[cur] = pare + 1;
			if(ans[cur] > N) {
				ans[cur] = pare -1;
			}
		} else {
			ans[cur] = pare;
		}

		for(auto next: to[cur]) {
			dfs(next.first, next.second, next.second == ans[cur]);
		}

	}
set<ll> root[100005];

int main(){
	cin >> N >> M;
	rep(i, M) {
		ll u, v, c;
		cin >> u >> v >> c;
		u--;v--;

		root[u].insert(c);
		root[v].insert(c);

		to[u].push_back(make_pair(v, c));
		to[v].push_back(make_pair(u, c));
	}
	rep(i, N) ans[i] = -1;
	dfs(0, 1, false);
	rep(i, N) cout << ans[i] << endl;;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)

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

    int n;
    cin >> n;

    vector<int> a(n), b(n), d(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) d[i] = b[i] - a[i]; // d>0なら[],B選択が有利

    vector<int> even(n / 2), odd(n / 2);
    rep(i, n / 2) even[i] = d[i * 2];
    rep(i, n / 2) odd[i] = d[i * 2 + 1];

    sort(even.begin(), even.end(), greater<int>());
    sort(odd.begin(), odd.end(), greater<int>());

    int64_t ans = 0;
    rep(i, n / 2)
    {
        int t = even[i] + odd[i];
        if (t > 0)
            ans += t;
    }
    rep(i, n) ans += a[i];
    cout << ans << '\n';

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n)    for(int i=0;i<(int)n;i++)
using ll = long long;
using P = pair<int,int>;
bool chtr(vector<vector<ll>> a){
    ll n=a.at(0).size();
    rep(i,n-1){
        rep(j,n-1){
            if((a.at(i+1).at(j+1)-a.at(i).at(j+1))!=(a.at(i+1).at(j)-a.at(i).at(j))){
                return true;
            }
        }
    }
    return false;
}
ll minh(vector<ll> a){
    sort(a.begin(),a.end());
    return a.at(0);
}
int main(){
    ll n;   cin>>n;
    vector<vector<ll>> a(n,vector<ll>(n));
    vector<ll> b(n),c(n);
    b.at(0)=0;
    rep(i,n){
        rep(j,n){
            cin>>a.at(i).at(j);
        }
    }
    if(chtr(a)){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
        rep(i,n-1){
            b.at(i+1)=a.at(i+1).at(0)-a.at(0).at(0);
        }
        ll adjust=abs(minh(b));
        rep(i,n){
            b.at(i)+=adjust;
            c.at(i)=a.at(0).at(i)-b.at(0);
        }
        rep(i,n){
            cout<<b.at(i)<<" ";
        }
        cout<<endl;
        rep(i,n){
            cout<<c.at(i)<<" ";
        }
        cout<<endl;
    }
}


#include<ctime>
#include<cstdio>
#include<cctype>
#define ll long long
using namespace std;
const ll N=2e5+7;
ll read(){
	char c;
	ll x=0,f=1;
	while(!isdigit(c=getchar()))
		f-=2*(c=='-');
	while(isdigit(c)){
		x=x*10+f*(c-48);
		c=getchar();
	}
	return x;
}
ll n,w,s,t,m,p,f,a[N];
int main(){
	#ifndef ONLINE_JUDGE
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
	#endif
	clock_t t1=clock();
	//--------
	n=read();
	w=read();
	for(ll i=1;i<=n;++i){
		s=read();
		t=read();
		p=read();
		a[s]+=p;
		a[t]-=p;
		if(m<t)
			m=t;
	}
	for(ll i=0;i<=m;++i)
		a[i]+=a[i-1];
	for(ll i=0;i<=m;++i){
		if(a[i]>w)
			f=1;
	}
	if(f)
		puts("No");
	else
		puts("Yes");
	//--------
	fprintf(stderr,"%0.3lfs",1.0*(clock()-t1)/CLOCKS_PER_SEC);
	return 0;
}

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

int main(){
	ll N, T;
	cin >> N >> T;
	vector<ll> A(N);
	for(auto &x: A) cin >> x;
	vector<ll> q;
	for(int bit = 0; bit < (1<<(N-N/2)); ++bit){
		ll sum = 0;
		for(int i = 0; i < N-N/2; ++i){
			if(bit&(1LL<<i)) sum += A[i+N/2];
		}
		q.push_back(sum);
	}
	sort(q.begin(), q.end());
	q.push_back(1LL<<60);
	ll res = 0;
	for(int bit = 0; bit < (1<<(N/2)); ++bit){
		ll sum = 0;
		for(int i = 0; i < N/2; ++i){
			if(bit&(1LL<<i)) sum += A[i];
		}
		if(sum > T) continue;
		auto it = upper_bound(q.begin(), q.end(), T - sum) - q.begin();
		it--;
		res = max(res, sum + q[it]);
	}
	cout << res << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define u unsigned
#define ull unsigned long long
#define ld long double
#define pb push_back
#define fasterInOut ios::sync_with_stdio(false); cin.tie(0);
#define pi acos(-1)
#define f(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,a,b) for(int i=(a);i>=(b);i--)
#define MAX 1000000

void function(int x);

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("C:/Users/ASUS/Desktop/inout/input.txt", "r", stdin);
    freopen("C:/Users/ASUS/Desktop/inout/output.txt", "w", stdout);
    #endif

    int a,b,c;
    cin>>a>>b>>c;
    if(a==b)
    	cout<<c<<endl;
    else if(b==c)
    	cout<<a<<endl;
    else if(a==c)
    	cout<<b<<endl;
    else if(a==b && b==c)
    	cout<<a<<endl;
    else
    	cout<<"0"<<endl;

    return 0;
}

#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<memory.h>
#include<vector>
#include<math.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b)
        cout<<c;
    else if(a==c)
        cout<<b;
    else if(b==c)
        cout<<a;
    else
        cout<<0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
int main() {
    string s;
    cin>>s;
    ll i,j;
    ll f=0;
    ll n=s.size();
    for(i=0;i<n;i+=2)
    {
        if(s[i]>='a'&&s[i]<='z')
        {

        }
        else
        {
            f=1;
        }
    }
    if(!f)
    {
        for(i=1;i<n;i+=2)
        {
            if(s[i]>='A'&&s[i]<='Z')
            {

            }
            else
            {
                f=1;
            }
        }
    }
    if(!f)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}

/*	2020-12-25	*/
#include <bits/stdc++.h>
#define all(s) (s).begin(),(s).end()
#define rall(s) (s).rbegin(),(s).rend()
#define uni(s) (s).erase(unique(all(s)),(s).end())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const int INF = (int)(1e9) + 10;

bool check(int x,int base){
	while (x){
		if (x % base == 7) return false;
		x /= base;
	}
	return true;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 1; i <= N; i++)
		if (check(i,10) && check(i,8)) ans++;
	cout << ans;
	return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
double eps = 1e-12;
#define fr(i,e) for(int i=0;i<n;i++)
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

int main()
{
 fast_cin();
 ll t;
 t=1;
 for(int it=1;it<=t;it++) {
     ll min=INT32_MAX;
     for(int i=0;i<4;i++)
     {
         ll a;
         cin>>a;
         if(a<min)
         min=a;
     }

    cout<<min<<endl;
 }
 return 0;
}

#include<bits/stdc++.h>
using namespace std;
signed main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(c&1){
		if(a<0&&b>0){
			return 0&puts("<");
		}
		if(a>0&&b<0){
			return 0&puts(">");
		}
		if(a==b){
			return 0&puts("=");
		}
		if(a<b){
			puts("<");
		}
		if(a>b){
			puts(">");
		}
	}
	else{
		a=abs(a),b=abs(b);
		if(a==b){
			return 0&puts("=");
		}
		if(a<b){
			puts("<");
		}
		if(a>b){
			puts(">");
		}
	}
	return 0;
}


#include <algorithm>
#include <iostream>
#include <iterator>
#include <sstream>
#include <utility>
#include <cstdarg>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cctype>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define File
#define tab    char(9)
#define line   char(10)
#define space  char(32)
#define hell   int(998244353)
#define mod    int(1000000007)
#define MOD(x, y)     (((x) % (y) + (y)) % (y))
#define input_array(arr)  for(auto &_: arr) cin >> _
#define Saitama ios_base::sync_with_stdio(false); cin.tie(NULL)
#define rep(var, start, end) for(int var = start; var < end; var++)
#define output_array(arr) for(auto &_: arr) cout << _ << space; cout << line

#ifndef bug
#define debug(x)            cerr << '[' << #x << " = " << x << ']' << line
#define debug2(x, y)        cerr << '[' << #x << " = " << x << ']' << space \
                                 << '[' << #y << " = " << y << ']' << line
#define debug3(x, y, z)     cerr << '[' << #x << " = " << x << ']' << space \
                                 << '[' << #y << " = " << y << ']' << space \
                                 << '[' << #z << " = " << z << ']' << line
#define debug4(x, y, z, _)  cerr << '[' << #x << " = " << x << ']' << space \
                                 << '[' << #y << " = " << y << ']' << space \
                                 << '[' << #z << " = " << z << ']' << space \
                                 << '[' << #_ << " = " << _ << ']' << line
#define bug
#endif

typedef long long ll;   // use %lld
typedef long double ld; // use %lf

using namespace std;

vector<ll> prime_factors(ll num)
{
	vector<ll> ans;

	// 1 is not included in the implementation
	while(num % 2){
		ans.push_back(2);
		num /= 2;
	}

	for(int i = 3; i * i <= num; i += 2){
		while(num % i == 0){
			ans.push_back(i);
			num /= i;
		}
	}

	// if the number was prime (greater than 2)
	if(num > 2)
		ans.push_back(num);

	return ans;
}

const ld pi = 3.14159265358979323846;

void tests()
{
	int rows, cols;
	cin >> rows >> cols;

	vector<int> arr(rows * cols);
	input_array(arr);

	int minimum = *min_element(arr.begin(), arr.end());

	ll ans = 0;

	rep(i, 0, rows * cols){
		ans += arr[i] - minimum;
	}

	cout << ans << line;
}

int32_t main()
{
	Saitama;

	#ifndef File
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

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

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

	return 0;
}

/*NEVER GIVE UP*/
/*First try brute force and check if it is in the range of time complexity*/
/*Then try to solve the problem in mathematical form*/
/*Then try to imagine how the final ans will look like*/
/*Write on paper if still not able to get*/
/*Try to think diff. algorithms and data structures that could solve the problem*/
#include <bits/stdc++.h>
using namespace std;
int main()
{long long r=0,c=0,s=0,min=1000;
    cin>>r>>c;
    long long a[r][c];
    for(long long i=0;i<r;i++)
    {
        for(long long j=0;j<c;j++)
        {
            cin>>a[i][j];
            if(a[i][j]<min)
            min=a[i][j];
        }
    }
    for(long long i=0;i<r;i++)
    {
        for(long long j=0;j<c;j++)
        s+=(a[i][j]-min);
    }
    cout<<s;
}


// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const int MOD = 1e9+7;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

int n, m;
int a[128], b[128];
int k;
int c[20], d[20];

int count ( int s[20] ) {
    int cnt = 0;

    int dish[128] = {};
    rep(i, k) {
        if ( s[i] == 0 ) ++dish[c[i]];
        else ++dish[d[i]];
    }

    rep(i, m) {
        if ( dish[a[i]] >= 1 && dish[b[i]] >= 1 ) ++cnt;
    }

    return cnt;
}

int solve ( int s[20], int depth = 0 ) {
    if ( depth == k ) {
        return count(s);
    }

    int ans = 0;
    rep(i, 2) {
        s[depth] = i;
        ans = max(ans, solve(s, depth+1));
    }

    return ans;
}

int main()
{
    cin >> n >> m;
    rep(i, m) cin >> a[i] >> b[i];
    cin >> k;
    rep(i, k) cin >> c[i] >> d[i];

    int s[20] = {};
    int ans = solve(s);
    cout << ans << endl;
}

#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define drep(i,j,n) for(int i=0;i<(int)(n-1);i++)for(int j=i+1;j<(int)(n);j++)
#define trep(i,j,k,n) for(int i=0;i<(int)(n-2);i++)for(int j=i+1;j<(int)(n-1);j++)for(int k=j+1;k<(int)(n);k++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yes(ans) if(ans)printf("yes\n");else printf("no\n")
#define Yes(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YES(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define vector3d(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
const int MOD2=998244353;
const int INF=1<<30;
const ll INF2=(ll)1<<60;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T,class L>void scan(pair<T, L>& p){scan(p.first);scan(p.second);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T,class L>void print(const pair<T, L>& p){print(p.first);putchar(' ');print(p.second);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll modinv(ll a, ll m) {ll b = m, u = 1, v = 0;while (b) {ll t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}
template<class T> void chmax(T &a,const T b){if(b>a)a=b;}
template<class T> void chmin(T &a,const T b){if(b<a)a=b;}

int main(){
    INT(n,m);
    vector<int> a(n);
    vector<int> minv(n,INF);
    in(a);
    vector<vector<int>> graph(n);
    int from,to,x,ans=-INF;
    rep(i,m){
        in(from,to);
        graph[from-1].push_back(to-1);
    }
    rep(i,n){
        rep(j,graph[i].size()){
            chmin(minv[graph[i][j]],a[i]);
            chmin(minv[graph[i][j]],minv[i]);
        }
    }
    rep(i,n)if(minv[i]!=INF)chmax(ans,a[i]-minv[i]);
    out(ans);
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

template <typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef unsigned long long ull;
#define pi 3.14159265358979323846264338327950
#define ll long long
#define ld long double
#define boost ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)((x).size())
#define mem1(a) memset(a, -1, sizeof(a))
#define mem0(a) memset(a, 0, sizeof(a))

////debug template-----------------------------
#ifndef ONLINE_JUDGE
#define what(x...)                \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define what(x...)
#endif
//----
void __print(int x) { cerr << x; }
void __print(ll x) { cerr << x; }
void __print(ull x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(ld x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
/////--------Debug template End----------->
////Deepak Prajapati----------------------------------------------->

const ll mxN = 1e5 + 10;
const ld eps = 1e-6;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

// vector<pair<int, int>> moves = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
// vector<vector<int>> g;
// vector<bool> vis;

void solve(int tc)
{
    vector<int> a(3);
    for (auto &&i : a)
    {
        cin >> i;
    }
    sort(all(a));
    cout << a[1] + a[2] << "\n";
}

int main()
{
    boost;
    cout << setprecision(10) << fixed;
    int tc = 1;
    // cal();
    // sieve();
    // cin >> tc;
    for (int i = 1; i <= tc; i++)
    {
        // cout << "Case #" << i << ": ";
        solve(i);
    }
#ifndef ONLINE_JUDGE
    cerr << "Time: " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << " ms\n";
#endif
    return 0;
}

#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <bitset>
#include <string>
#include <cstdio>
#include <cmath>
#include <climits>
#include <fstream>
#include <chrono>
using namespace std;

const long long INF = LLONG_MAX;
const long long MOD = 1000000007;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

// input
int sx, sy;
vector<vector<int>> tile(50, vector<int>(50)), point(50, vector<int>(50));

//     UP,0
//     DOWN,1
//     LEFT,2
//     RIGHT,3
const int dx[] = {0, 0, -1, 1};
const int dy[] = {-1, 1, 0, 0};
char output(int move)
{
    switch (move)
    {
    case 0:
        return 'U';
    case 1:
        return 'D';
    case 2:
        return 'L';
    case 3:
        return 'R';
    default:
        return 'U';
    }
}

void change(int& x, int& y, const int& move)
{
    x += dx[move];
    y += dy[move];
}

int move_point(const int& now_x, const int& now_y, const int& move, const vector<char>& visited)
{
    int next_x = now_x + dx[move];
    int next_y = now_y + dy[move];

    if (next_x < 0 || 50 <= next_x) return 0;
    if (next_y < 0 || 50 <= next_y) return 0;

    if (visited[tile[next_y][next_x]] == 'o') return 0;
    if (tile[next_y][next_x] == tile[now_y][now_x]) return 0;

    return point[next_y][next_x];
}

int main(void)
{
    // input
    cin >> sy >> sx;
    for (int y = 0; y < 50; y++)
    {
        for (int x = 0; x < 50; x++)
        {
            cin >> tile[y][x];
        }
    }
    for (int y = 0; y < 50; y++)
    {
        for (int x = 0; x < 50; x++)
        {
            cin >> point[y][x];
        }
    }

    vector<char> visited(tile[49][49] + 1, 'x');
    string ans;

    auto start = chrono::system_clock::now();
    auto now = chrono::system_clock::now();
    int now_x = sx, now_y = sy;
    do
    {
        visited[tile[now_y][now_x]] = 'o';

        int max_point = 0;
        int move;
        for (int i = 0; i < 4; ++i)
        {
            if (move_point(now_x, now_y, i, visited) > 0)
            {
                int point = 0;
                switch (i)
                {
                case 0: point = now_y - 1; break;
                case 1: point = 50 - now_y; break;
                case 2: point = now_x - 1; break;
                case 3: point = 50 - now_x; break;
                }

                if (max_point < point)
                {
                    max_point = point;
                    move = i;
                }
            }
        }

        // move
        if (max_point == 0)
        {
            break;
        }
        else
        {
            change(now_x, now_y, move);
            ans += output(move);
        }

        now = chrono::system_clock::now();
    }
    while (chrono::duration_cast<chrono::milliseconds>(now - start).count() < 1900);

    cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, a[N];

bool solve() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	if (n % 2)
		return false;

	map<int, int> freq;
	for (int i = 1; i <= n; i++) {
		freq[a[i]]++;
	}

	for (auto [x, f] : freq) {
		if (f % 2)
			return true;
	}
	return false;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int t;
	cin >> t;

	while (t--) {
		cout << (solve() ? "First" : "Second") << '\n';
	}

	return 0;
}

#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<'\n'
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define sz(A) (int)A.size()
#define N 1014159
#define  vi vector<int>
#define  v  vector
#define die exit(0)
#define alln(arr) arr+1 , arr+1+n
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> oset;

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).

#define in input_int()
#define ins input_string()
bool sb(int a,int i){return (a&(1LL<<i))>0;}
int p2(int a){return (1LL<<a);}
int input_int(){int a;cin>>a;return a;}
string input_string(){string s;cin>>s;return s;}
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int ceil(int a,int b){return (a+b-1)/b;}
int ct,visited[N],ans;
vi adj[N];
int n,m,k,a,b,c,d,x,y,arr[N];
void clr()
{
    forn(i,0,n+10)adj[i].clear(),visited[i]=0,arr[i]=0;
}

string s;
void solve()
{
    cin>>n;
    map<int,int>m;
    forn(i,1,n)
    {
        m[in]++;
    }
    int ans=0;
    for(auto i : m)
    {
        ans+=(n-i.Y)*i.Y;
    }
    cout<<ans/2;
}

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin>>t;
    forn(i,1,t)
    {
        //cout<<"Case #"<<i<<": ";
        solve();
        nl;
    }

    return 0;

}
//       clang++ c.cpp ; ./a.out < a.txt ;


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

const double pi=3.141592653589793;
const int64_t inf=1L<<60;
//const int64_t mod=1000000007;
const int64_t mod=998244353;

int main(){
  int N,M;
  cin>>N>>M;
  map<int,set<int>> black;
  set<int> move;
  move.insert(N);
  for(int i=0; i<M; i++){
    int x,y;
    cin>>x>>y;
    black[x].insert(y);
  }
  set<int> pushlist;
  set<int> poplist;
  for(auto m : black){
    auto ylist=m.second;
    for(int y : ylist){
      if(move.count(y)){
        if(!move.count(y+1)&&!move.count(y-1)){ //隣がいけないならダメ
          poplist.insert(y);
        }
      }
      else{
        if(move.count(y+1)||move.count(y-1)){ //隣がいけるならok
          pushlist.insert(y);
        }
      }
    }
    for(int i : poplist){
      move.erase(i);
      poplist.erase(i);
    }
    for(int i : pushlist){
      move.insert(i);
      pushlist.erase(i);
    }
  }
  cout<<move.size()<<endl;
}

#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define read read1<ll>()
# define Type template<typename T>
Type T read1(){
	T t=0;
	char k;
	bool vis=0;
	do (k=getchar())=='-'&&(vis=1);while('0'>k||k>'9');
	while('0'<=k&&k<='9')t=(t<<3)+(t<<1)+(k^'0'),k=getchar();
	return vis?-t:t;
}
# define fre(k) freopen(k".in","r",stdin);freopen(k".out","w",stdout)
int s,n;
pair<int,int>a[200005];
map<int,queue<int> >ma;
map<int,bool>h;
int vis[200005],ans;
vector<int>G[200005];
void dfs(int n){
	if(vis[n]==2)return;
	ans+=vis[n];
	for(auto i:G[n])dfs(i);
	vis[n]=2;
}
int main(){
	n=read,s=read;
	a[0]=make_pair(0,n);
	for(int i=1;i<=s;++i)
		a[i].first=read,a[i].second=read;
	sort(a+1,a+s+1);
	for(int i=s;~i;--i)
		if(h[a[i].second]){
			queue<int>&w=ma[a[i].second];
			while(w.size()&&a[w.front()].first>a[i].first)G[i].push_back(w.front()),w.pop();
			ma[a[i].second-1].push(i);
			ma[a[i].second+1].push(i);
		}else{
			h[a[i].second]=1;vis[i]=1;
			queue<int>&w=ma[a[i].second];
			while(w.size()&&a[w.front()].first>a[i].first)G[i].push_back(w.front()),w.pop();
			ma[a[i].second-1].push(i);
			ma[a[i].second+1].push(i);
		}
	dfs(0);cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#pragma GCC optimize ("-O3")
#define int long long
#define ld long double
#define endl "\n"

#define rep(i,begin,end) for (__typeof(end) i=begin-(begin>end); i!=(end)-(begin>end); i+=1-2*(begin>end))
#define umap unordered_map
#define pq priority_queue
#define pb push_back
#define mp make_pair
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define mii map<int,int>
#define pii pair<int,int>
#define vc vector
#define vi vc<int>
#define vvi vc<vi>
#define all(v) v.begin(),v.end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define w(t) int t; cin>>t; rep(tc,0,t)
#define clr(a,x) memset(a,x,sizeof a)

#define chkbit(x,i) ((x)&(1LL<<(i)))
#define setbit(x,i) ((x)|(1LL<<(i)))
#define setbits(x)  __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
#define ps(x,y) fixed<<setprecision(y)<<x
#define print(a, n) rep(i,0,n) cout<<a[i]<<" "; cout<<endl;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int mod = 1e9+7;
const int mod2 = 998244353;
const int N = 3e5;
const int inf = 1e18;
const ld PI = 3.141592653589793;

//=====================================================

template<typename... T>
void in(T&... args) {((cin>>args), ...);}
template<typename... T>
void out(T&&... args) {((cout<<args<<" "), ...);}
template<typename... T>
void outln(T&&... args) {((cout<<args<<" "), ...); cout<<endl;}

int nxt(){int x;cin>>x;return x;}
int add(int a,int b,int mod){int res=(a+b)%mod;return (res<0)?res+mod:res;}
int mul(int a,int b,int mod){int res=(a*1LL*b)%mod;return (res<0)?res+mod:res;}
int range(int x,int y,int z) {return (x >= y && x <= z);}

//=====================================================

void solve(){
    int n = nxt();
    vector<int> c(1001);

    rep (i, 0, n) {
        int x = nxt();
        for (int i = 1; i*i <= x; i++){
            if (x % i == 0){
                c[i]++;
                if (i*i != x)
                    c[x/i]++;
            }
        }
    }

    int ans = 0;
    rep (i, 2, 1001){
        if (c[i] >= c[ans])
            ans = i;
    }

    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    solve();
    return 0;
}

#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <utility>
#include <complex>
#include <chrono>
using namespace std;
using namespace std::chrono;

typedef long long int lli;
typedef long double ld;
typedef vector<lli> vl;
typedef vector<ld> vd;
typedef map<lli,lli> ml;
typedef unordered_map<lli,lli> uml;
typedef pair<lli,lli> pl;
typedef set<lli> sl;
typedef vector<pl> vp;
typedef queue<lli> ql;
typedef priority_queue<lli> pql;
typedef list<lli> ll;
typedef vector<ll> graph;

# define pb push_back
# define mp make_pair
# define f first
# define sec second
# define itr iterator
# define MOD 1000000007
# define INF 1000000000000000
# define all(x) x.begin(), x.end()
# define rall(a) a.begin(), a.end(), greater<lli>()
# define ins insert
# define ms(a,x) memset(a, x, sizeof(a))
# define rep(i,n) for(i=0;i<n;i++)
# define wrep(i,a,b) for(i=a;i<b;i++)
# define M 1500001;
/*
void knapsack(lli n, lli m, vl va, vl vb){
    lli i, w;
    lli k[n+1][m+1];
    k[n][m] = -1;
    for(i=0;i<=n;i++){
        for(w=0;w<=m;w++){
            if(i==0 || w==0){
                k[i][w]=0;
            }
            else if(va[i-1]<=w){
                k[i][w] = max(k[i-1][w], k[i-1][w-va[i-1]]+ vb[i-1]);
            }
            else{
                k[i][w] = k[i-1][w];
            }
        }
    }
    cout<<k[n][m]<<endl;
}
bool comp(pl a, pl b){
    return a.f<b.f;
}
bool comp(lli a, lli b){
    return abs(a)<abs(b);
}
lli cmb(lli n, lli r){
    if(n==r){
        return 1;
    }
    lli i, pdt = 1;
    r = max(r,n-r);
    for(i=1;i<=n-r;i++){
        pdt *= (r+i);
        pdt /= i;
    }
    return pdt;
}
lli per(lli n, lli r){
    lli i;
    lli pdt = 1;
    for(i=1;i<=r;i++){
        pdt *= n-r+i;
    }
    return pdt;

}
// Binomial coeff Table // Combination Table
lli dp[2001][2001];
void foo(){
    dp[0][0] = 1;
    lli i, j;
    for (i = 1; i < 1001; i++) {
        dp[i][0] = 1;
        for (j = 1; j <= i; j++) {
            dp[i][j] = (dp[i-1][j] + dp[i-1][j-1]) % MOD;
        }
    }
}

//cout << fixed << setprecision(9) << t << endl;
//sieve Table
int sv[M];
vl prm;
void sieve(){
    lli i, j;
    for(i=2;i<M;i++){
      if(sv[i]!=0){
        continue;
      }
      sv[i] = -1;
      prm.pb(i);
      for(j=2;j*i<M;j++){
        sv[i*j] = 1;
      }
    }
    return;
}
lli fexpo(lli a, lli b){
  if(a==1) return 1;
  if(b==0) return 1;
  if(b==1) return a%MOD;
  lli ans = fexpo(a,b/2)%MOD;
  if(b%2==0) return (ans*ans)%MOD;
  else return (((a*ans)%MOD)*ans)%MOD;
}
lli fact[M];
lli inv_fact[M];
void foo(){
  lli i;
  fact[0] = 1;
  for(i=1;i<M;i++){
    fact[i] = (i*fact[i-1])%MOD;
  }
  inv_fact[M-1] = fexpo(fact[M-1],MOD-2);
  for(i=M-2;i>=0;i--){
    inv_fact[i] = ((i+1)*inv_fact[i+1])%MOD;
  }
}
lli cmb(lli n, lli r){
  return (((fact[n]*inv_fact[r])%MOD)*(inv_fact[n-r]))%MOD;
}
void bezout(lli a, lli b, lli &x, lli &y){
  if(a==0){
    x = 0;
    y = 1;
    return;
  }
  lli x1, y1;
  bezout(b%a,a,x1,y1);
  x = y1 - (b/a)*x1;
  y = x1;
  return;
}
*/

void solve(){
    lli n, i, m=0, q=0, mx=-INF, mn=INF, k=0, j=0, c=0, d=0, t = 0, sm = 0, pdt = 1;
    cin >> n;
    //lli v[n];

    if(n%2==0){
      cout<<"White"<<endl;
    }
    else{
      cout<<"Black"<<endl;
    }

    return;
}

int main() {
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    int t;
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
    //cin >> t;
    t = 1;
    while(t--){
        solve();
    }
    return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <random>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

const int mod = 998244353;
int n;
int w[100];
int fact[101];
int dp[101][101][5101];

signed main() {
	int i, j, k;

	cin >> n;
	rep(i, n) cin >> w[i];

	fact[0] = 1;
	for (i = 1; i <= n; i++) {
		fact[i] = fact[i - 1] * i % mod;
	}

	int sumW = 0;
	rep(i, n) sumW += w[i];
	if (sumW % 2 == 1) {
		cout << 0 << endl;
		return 0;
	}

	dp[0][0][0] = 1;
	rep(i, n) {
		for (j = 0; j <= i; j++) {
			rep(k, 5001) {
				dp[i + 1][j][k] += dp[i][j][k];
				dp[i + 1][j][k] %= mod;
				dp[i + 1][j + 1][k + w[i]] += dp[i][j][k];
				dp[i + 1][j + 1][k + w[i]] %= mod;
			}
		}
	}

	int ans = 0;
	for (i = 1; i < n; i++) {
		int res = dp[n][i][sumW / 2];
		ans += res * fact[i] % mod * fact[n - i] % mod;
		ans %= mod;
	}

	cout << ans << endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define pb push_back
#define mod 1000000007
#define MAXN  100000
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int dx8[]={1,-1,0,0,1,1,-1,-1};
int dy8[]={0,0,1,-1,1,-1,1,-1};
int spf[MAXN];

void sieve()
{
	int i, j;
	for (i = 0; i < MAXN; i++)
		spf[i] = i;
	for (i = 4; i < MAXN; i += 2)
		spf[i] = 2;
	for (i = 3; i * i < MAXN; i++)
	{
		if (spf[i] == i)
		{
			for (j = i * i; j < MAXN; j += i)
			{
				if (spf[j] == j)
					spf[j] = i;
			}
		}
	}
}

ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
bool sortbyme(const pair<int,int> &a,
              const pair<int,int> &b){
	return (a.first+a.second > b.first+b.second);

}

long double sq(long double n){
    long double l=0,r=n;
    long double mid=l+(r-l)/2;

    while(r-l>=0.0000001){
         mid=l+(r-l)/2;
         if(mid*mid<n){
             l=mid;

         }
         else{
             r=mid;

         }

    }
    // cout<<mid<<endl;
    return mid;

}

void solve(){
ll n;
cin>>n;
string s;
cin>>s;
ll ans=0;
unordered_map<ll,ll> m;
 ll sum=0;

vector<ll> a(n,0);

        for(ll i=0;i<n;i++)
        {
            if(s[i]=='G')a[i]=1e6;
            else if(s[i]=='C')a[i]=-1e6;
            else if(s[i]=='T')a[i]=1;
            else if(s[i]=='A')
                      a[i]=-1;
        }

        for(ll i=0;i<n;i++)
        {
            sum+=a[i];
            if(sum==0)ans++;
            if(m[sum])ans+=m[sum];
            m[sum]++;
        }
        cout<<ans<<endl;

return;

}

int main()
{
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
    fast;

    ll t;
    t=1;
   // cin>>t;
    while(t--){
    	solve();
    }

#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <queue>
using namespace std;
# define rep(i,a,b) for(int i=(a); i<=(b); ++i)
# define drep(i,a,b) for(int i=(a); i>=(b); --i)
typedef long long int_;
inline int readint(){
	int a = 0; char c = getchar(), f = 1;
	for(; c<'0'||c>'9'; c=getchar())
		if(c == '-') f = -f;
	for(; '0'<=c&&c<='9'; c=getchar())
		a = (a<<3)+(a<<1)+(c^48);
	return a*f;
}
inline void writeint(int_ x){
	if(x > 9) writeint(x/10);
	putchar((x-x/10*10)^48);
}

const int MaxN = 100005;
const int Mod = 1e9+7;
int a[MaxN], f[MaxN];

int main(){
	int n = readint();
	f[0] = 1, f[1] = 2;
	rep(i,2,n)
		f[i] = (f[i-1]+f[i-2])%Mod;
	a[1] = readint();
	int ans = 1ll*a[1]*f[n-1]%Mod;
	rep(i,2,n){
		a[i] = readint();
		int t = 1ll*f[max(i-3,0)]*f[max(n-i-1,0)]%Mod; // '-'
		t = (1ll*f[i-2]*f[n-i]%Mod+Mod-t)%Mod; // +
		ans = (ans+1ll*t*a[i])%Mod;
	}
	printf("%d\n",ans);
	return 0;
}

#include<bits/stdc++.h>

typedef   long long  int ll;
typedef  long double ld;
typedef std::vector<ll> vi;
typedef std::vector<std::vector<ll> > vv;
typedef std::vector<std::pair<ll,ll> > pii;

#define mod 1000000007
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,b) for(i=a;i<b;i++)
#define forr(i,a,b) for(i=a;i>=b;i--)
#define mp make_pair
#define pb(x) push_back(x)
#define fi first
#define se second
#define print(vec,a,b) for(ll i=a;i<b;i++) cout<<vec[i]<<" ";cout<<endl;
#define all(a) a.begin(),a.end()
#define input(vec,a,b) for(ll i = a;i<b;i++) cin>>vec[i];
#define ms(a,val) memset(a,val,sizeof(a))
using namespace std;

const int N = 2e5+ 5;

ll expo_pow(ll x, ll y) {
	if (y == 0)
		return 1;
	y = y % (mod - 1);
	x %= mod;
	if (y == 0)
		y = mod - 1;
	ll res = 1;
	while (y) {
		if (y & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		y >>= 1;
	}
	return res;
}

ll modInverse(ll a, ll m = mod) {
	return expo_pow(a, m - 2);
}

void solve(){
            ll i,j,n,m,k;
			cin>>n;

			vi a(n,0);
			input(a,0,n);

			map<ll, vector<ll> > M;

			i = 1;
			bool done = false;
			while( i < 202)
			{
				if( n < 10 && i == (1LL<<n))
				  break;

				vi temp;
				ll sum = 0;
				fo(j,0,min(n,16LL))
				{
					if((1LL<<j)&i)
					{
						sum+=a[j];
						temp.pb(j+1);
					}
				}
				sum = sum%200;
				if(M.find(sum) != M.end())
				{
					done = true;
					cout<<"Yes"<<endl;
					cout<<M[sum].size()<<" ";
					for(auto it : M[sum])
					 cout<<it<<" ";
					cout<<endl;
					//sort(all(temp));
					cout<<temp.size()<<" ";
					for(auto it : temp)
					 cout<<it<<" ";
					cout<<endl;
					return ;
				}
				else
				{
					//sort(all(temp));
					M[sum] = temp;
				}
				i++;
			}
			cout<<"No"<<endl;

}

int main()
{
     IO;
      ll t=1,i;
      //cin>>t;

      while(t--)
      {

          solve();
      }
    return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
//#define int long long
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PI = pair<pair<int,int>,int>;
using PL = pair<long long, long long>;
using PLL = pair<pair<long long, long long>, long long>;
using Pxy = pair<long double, long double>;
using Tiib = tuple<int, int, bool>;
using vvl = vector<vector<ll>>;
const int INF = 1001001007;
const int modd = 1000000007;
const long long modl = 1000000007LL;
const long long mod = 998244353LL;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(){
    cout << "Yes" << endl;
}

void no (){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main(){
    int n; cin >> n;
    ll lcm = 1LL;
    repp(i,n+1,2){
        ll a = i;
        ll g = gcds(lcm,a);
        lcm = lcm / g * a;
    }
    cout << lcm + 1LL << endl;
}

#include<bits/stdc++.h>

using namespace std;
using Graph=vector<vector<int>>;

void dfs(int v,vector<bool> &flag,Graph &g){
  if(!flag[v]){return;}
  flag[v]=false;
  for(auto &nx : g[v]){dfs(nx,flag,g);}
}

int main(){
  int n,res=0;
  cin >> n;
  vector<int> a(n);
  vector<bool> flag(200005,false);
  Graph g(200005);
  for(auto &nx : a){
    cin >> nx;
    if(!flag[nx]){flag[nx]=true;res++;}
  }
  int p=0,q=n-1;
  while(p<q){
    g[a[p]].push_back(a[q]);
    g[a[q]].push_back(a[p]);
    p++;q--;
  }
  for(int i=1;i<=200000;i++){
    if(flag[i]){
      res--;
      dfs(i,flag,g);
    }
  }
  cout << res;
}


#include "bits/stdc++.h"
using namespace std;
using li = long long;
const char newl = '\n';
template <class T> vector<vector<T>> vv(const unsigned int n, const unsigned int m, const T x) { return vector<vector<T>>(n, vector<T>(m, x)); }
template <class T> vector<vector<vector<T>>> vvv(const unsigned int n, const unsigned int m, const unsigned int k, const T x) { return vector<vector<vector<T>>>(n, vv(m, k, x)); }
template <class T> bool contains(const set<T>& s, const T& v) { return s.find(v) != s.end(); }
template <class T> bool contains(const unordered_set<T>& s, const T& v) { return s.find(v) != s.end(); }
template <class K, class V> bool contains_key(const map<K, V>& m, const K& v) { return m.find(v) != m.end(); }

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

    li n;
    cin >> n;
    string t;
    cin >> t;

    li ans;
    const string pattern = "110";
    const li rep = 1e10;
    if (n >= 3) {
        ans = 0;
        for (int start = 0; start < 3; ++start) {
            bool ok = true;
            for (int i = 0; i < n; ++i) {
                ok &= t[i] == pattern[(start + i) % 3];
            }
            if (ok) {
                ans = (rep * 3 - start - n + 3) / 3;
                break;
            }
        }

    } else if (n == 2) {
        if (t == "00") {
            ans = 0;
        } else if (t == "11") {
            ans = rep;
        } else if (t == "10") {
            ans = rep;
        } else { // 01
            ans = rep - 1;
        }
    } else {
        if (t == "1") {
            ans = 2 * rep;
        } else {
            ans = rep;
        }
    }
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const ll MOD = 1000000007;
#define mod(x) (x % MOD + MOD) % MOD

const int dx[4] = {+1, 0, -1, 0};
const int dy[4] = {0, -1, 0, +1};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, x;
    string s;
    cin >> n >> x >> s;
    int ans = x;
    for (char c : s)
    {
        if (c == 'x')
        {
            ans = max(ans - 1, 0);
        }
        else
        {
            ans++;
        }
    }
    cout << ans << endl;
}