#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  char ch;
  int Sum = 0, Count = 0;
  n /= 2;
  for (int i = 1; i <= n; i++) {
    cin >> ch;
    if (ch == '4' || ch == '7') {
      Count++;
    }
    Sum += ch - '0';
  }
  for (int i = 1; i <= n; i++) {
    cin >> ch;
    if (ch == '4' || ch == '7') {
      Count++;
    }
    Sum -= ch - '0';
  }
  cout << (Sum == 0 && Count == n * 2 ? "YES" : "NO");
  return 0;
}
