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