#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[200];
  int n, i, a = 0, b = 0, c = 0;
  cin >> n;
  cin >> s;
  for (i = 0; i < n; i++) {
    if (s[i] == '4' || s[i] == '7')
      a++;
    else
      break;
  }
  for (i = 0; i < n / 2; i++) b = b + s[i];
  for (i = n / 2; i < n; i++) c = c + s[i];
  if (a == n && b == c)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
