#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n >> s;
  bool l = true;
  int sum = 0;
  for (auto i = 0; i < n; ++i) {
    int a = s[i] - '0';
    if (a != 4 && a != 7) l = false;
    sum += (i < n / 2 ? a : -a);
  }
  cout << (l && sum == 0 ? "YES" : "NO") << endl;
  return 0;
}
