#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  int len, sum1 = 0, sum2 = 0, a = 0, b = 0, i;
  cin >> len >> x;
  for (int i = 0; i < (len) / 2; i++) {
    if (x[i] == '4') {
      sum1 += x[i];
      a++;
    } else if (x[i] == '7') {
      sum1 += x[i];
      b++;
    }
  }
  for (i = ((len - 1) / 2) + 1; i < len; i++) {
    if (x[i] == '4') {
      sum2 += x[i];
      a++;
    } else if (x[i] == '7') {
      sum2 += x[i];
      b++;
    }
  }
  if (sum1 == sum2 && (a + b) == len)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
