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

typedef long long ll;
using namespace std;

int gcd(int a, int b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

int lcm(int a, int b) { //最小公倍数
  return a * b / gcd(a, b);
}


int main()
{
  ll n,a[100010];
  cin>>n;
  rep(i,n)cin>>a[i];
  sort(a,a+n,greater<ll>());

  ll tate=0,yoko=0,cnt=0;

  rep(i,n-1){
    if(cnt==0&&a[i]==a[i+1]){
      tate=a[i];
      cnt=1;
      i++;
    }else if(cnt==1&&a[i]==a[i+1]){
      yoko=a[i];
      cnt=2;
    }
  }

  if(tate==0||yoko==0){
    cout<<0<<endl;
  }else{
    cout<<tate*yoko<<endl;
  }

  return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 2e5+23;

int a[N];
map<int, int> m;

void solve() {
  int n; scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a+i);
    ++m[a[i]];
  }
  sort(a, a+n, greater<int>());
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (!m[a[i]]) continue;
    for (int j = 1<<30; j >= a[i]; j >>= 1) {
      int t = 1;
      if (j-a[i] == a[i]) {
	t = 2;
      }
      if (m.count(j-a[i]) && m[j-a[i]] >= t) {
	++ans;
	--m[a[i]];
	--m[j-a[i]];
	break;
      }
    }
  }
  printf("%d", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}
