#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int N = 1e5 + 1;
const int V = 111;
const int E = 4 * V * V;
int prov(string s, int n) {
  for (int i = 0; i <= n - 1; i++)
    if (s[i] != '4' && s[i] != '7') return 0;
  return 1;
}
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int s1 = 0, s2 = 0;
  for (int i = 0; i <= n / 2 - 1; i++) {
    s1 += s[i] - '0';
    s2 += s[i + n / 2] - '0';
  }
  if (s1 == s2 && prov(s, n))
    puts("YES");
  else
    puts("NO");
  return 0;
}
