#include <bits/stdc++.h>
using namespace std;
bool isluck() {
  unsigned long long n, s1 = 0, s2 = 0;
  string s;
  cin >> n >> s;
  for (int register i = 0; i < n / 2; i++) {
    int x = (s[i] - '0') % 10;
    if (x != 4 && x != 7) return false;
    s1 += x;
  }
  for (int register i = n / 2; i < n; i++) {
    int x = (s[i] - '0') % 10;
    if (x != 4 && x != 7) return false;
    s2 += x;
  }
  return (s1 == s2);
}
int main() {
  isluck() ? cout << "YES" << endl : cout << "NO" << endl;
  return 0;
}
